Boost logo

Boost :

Subject: Re: [boost] Best method of checking for ==, <, streamability
From: Nevin Liber (nevin_at_[hidden])
Date: 2010-11-01 14:12:23

On 1 November 2010 12:15, Christopher Jefferson <chris_at_[hidden]> wrote:
> A user recently posted on boost-users asking for operator== support in boost::any. I have added this support to my private version, which extends spirit's implementation of any. I am interested in cleaning this up and submitting it to replace boost::any, if everyone is happy with this.

It depends on what its semantics are. I can get the functionality
that user posted by externally comparing the addresses of the
boost::any objects, so it isn't very useful.

Semantics that are, say:
1. Not equal of they are different types of objects.
2. Use they expression l == r if they are the same type of object.
3. Throw if l == r is ill-formed.

Would be useful.

> The major issue is that my implementation requires type support operator==, operator< , hash and operator<< / operator>>. Are there any techniques in boost for detecting the presence of these operators which are sufficiently reliable they could be used in boost::any?

As part of my BoostCon '10 talk on Type Erasure, I implemented the
stream insertion operator for boost::any (as an example, not a
proposal). Slides are at <>. My
is_ostreamable type trait is based on the implementation of
is_incrementable found in boost/detail/is_incrementable.hpp. (If you
want me to send it to you contact me off-list.)

What I'd like to see is more of these type traits: is_ostreamable,
is_equality_comparable, etc. I'm willing to contribute the first one.

 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

Boost list run by bdawes at, gregod at, cpdaniel at, john at