
6 Oct
2006
6 Oct
'06
3 p.m.
Vaclav Vesely wrote:
Hi,
I would like to do somethink like this:
class Base {...} class Derived: public Base {...}
optional<Base> x = Derived(); y->call_virtual_functions()
Current design of boost::optional doesn'g support this. But I wonder if it's to possible to extend it.
I created simple prototype to verify the technique (see attachment). It works this way:
optional<BaseT> - has attribut _value_holder of type value_holder<BaseT>* - _value_holder points to the instance of derived_value_holder<BaseT, DerivedT>, where DerivedT is the type of stored value
It looks a lot like Boost.Any. Have you looked at it? Fernando Cacciola SciSoft http://fcacciola.50webs.com