10 Oct
                
                    2006
                
            
            
                10 Oct
                
                '06
                
            
            
            
        
    
                4:31 p.m.
            
        Vaclav Vesely wrote:
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.
Perhaps you can use Boost.PtrContainer: typedef boost::ptr_vector< boost::nullable<Base> > OptionalContainer; ? -Thorsten