
AMDG On 07/24/2012 10:39 AM, Christophe Henry wrote:
<snip>
I find this an interesting question. I use the review to change a private but real project and replace all of my OO-style interfaces by TypeErasure. I got the following to compile and work (you need copy_constructible):
typedef any< boost::mpl::vector< boost::type_erasure::typeid_<>, boost::type_erasure::copy_constructible<>, boost::type_erasure::addable<>, boost::type_erasure::incrementable<>, boost::type_erasure::decrementable<> > > AnyA;
typedef any< boost::mpl::vector< boost::type_erasure::copy_constructible<>, boost::type_erasure::typeid_<>, boost::type_erasure::addable<> > > AnyB;
AnyA a(10); AnyB b = a;
OTOH, this does not compile: AnyB b2(10); AnyA a2=b2;
Right.
Which brings me to the following use case. Supposing I have 3 classes IA <- IB <- IC and 1 object of each held as shared_ptr, I can dynamic_pointer_cast from one to another. But if I have 3 any's of concepts A,B,C, B containing A's concepts + some more, and C containing B's concepts + some more, I can "upcast" as shown above from C to B and B to A, but not the other way around, right? Even if I have an object fulfilling A,B and C.
That's correct. As I replied to Fabio in another thread, this can be implemented, but requires some kind of reflection. If enough people need it, I can make it a priority.
PS: so far I got only one warning: check_match does not use its parameter op.
Fixed. In Christ, Steven Watanabe