On Mon, Oct 10, 2011 at 11:49 PM, Dave Abrahams
on Mon Oct 10 2011, Igor R
wrote: Yeah, as long as you're doing that with a runtime test, your only option is to use some kind of type erasure (boost::any, polymorphic base class, etc).
Or Boost.Variant.
(which is what I meant by etc.)
I think if you are going to use type erasure, Igor's suggestion is probably the approach most suited to a metaprogrammed system.
Thank you for your suggestions. It seems that one way or the other I'll have to bite the bullet and use (at least partially) a more traditional approach in my application. It all started when I saw that to avoid duplicating information among my classes I created a complex inheritance hierarchy. I didn't like it and I decided to try using some generative programming techniques to build my classes at compile-time. So far so good but then I was facing all kind of other problems like how to store these heterogeneous objects in containers or, like in the example above, mix run-time and compile-time tests...