On Wed, 22 Jan 2003, Jason House wrote: > Douglas Gregor wrote: > > template<typename ValueType> ValueType& any_cast(any & operand); > > template<typename ValueType> const ValueType& any_cast(const any & operand); > > > > If "operand" does not contain a value of type ValueType, any_cast throws > > bad_any_cast. Otherwise, it returns a reference to the held value. Why > > wouldn't we want this behavior? > > > so, with the new scheme, if someone does a conversion to a pointer type > and it fails, what happens? > does it return Null or does it throw bad_any_cast?
It depends only on whether you pass any_cast a boost::any lvalue or a boost::any pointer: in the former case, it will throw bad_any_cast and in the latter case it will return a null pointer. So with a boost::any variable 'x', the type of boost::any_cast<T*>(x) is T*& and the type of boost::any_cast<T*>(&x) is T**. Doug _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost