On Mon, Nov 1, 2010 at 9:16 AM, Nevin Liber
On 1 November 2010 08:57, Hossein Haeri
wrote: Is there any way to implement an operator == (and perhaps also operator !=) for objects of type boost::any so that different instances are always != and an instance is always only == to itself -- regardless of the respective values?
In case you're wondering why I'd interested in such operators, the answer is that I'm thinking of storing objects of type boost::any in an unordered_map.
Wouldn't this just be the address of the object (which isn't particularly useable as a key in a map)?
Actually it would be possible. For example, Adobe's Any version has a streaming operator (which throws I think if the stored type does not support streaming, or just does not accept it, one or the other). The way it does it can easily be extended to handle a == of the internal value (not just the type) as well. Hmm, perhaps it is time for an extended Boost.Any that supports 'concepts' of a sort of the stored types. Hmm, Boost.Proto could probably simplify the scaffolding a lot as well...