
Alexander Nasonov wrote:
Jorge Lodos wrote:
Hi The following is a partial solution for boost::any operations, including operator==. [ skiped ] This is different from any_cast in that it returns a reference, instead of a copy. Note also that this will never be used implicitely, you have to call operator ValueType&() explicitely.
any_cast already supports reference types.
Sure, but it returns a copy of the holded object. The described operator returns a reference to the holded object.
There is another way of doing this:
typedef mpl::vector< less<typeof(_1 == _2)> , plus<typeof(_1 + _2)> > ops; any<ops> a = 0; any<ops> b = a + a;
assert( b == a );
I have a partial solution but I want better multimethods.
Nice, thanks for sharing. Cheers Jorge