
10 Oct
2006
10 Oct
'06
8:11 a.m.
Fernando Cacciola wrote:
Vaclav Vesely wrote:
I would like to do somethink like this:
class Base {...} class Derived: public Base {...}
optional<Base> x = Derived(); y->call_virtual_functions()
It looks a lot like Boost.Any. Have you looked at it?
boost::any doesn't support derived classes as well. For example: any x = Derived(); any_cast<Base>(x).virtual_function(); // throws bad_any_cast And moreover boost::any is too general. I want to store only values of Base and its derived classes. Regards, Vaclav