
----- Original Message ----- From: "Christoph Heindl" <christoph.heindl@gmail.com> To: <boost@lists.boost.org> Sent: Tuesday, April 27, 2010 7:15 PM Subject: [boost] [any] boost::get style accessors
Hi all,
I couldn't find any boost::get<T> style accessors for boost::any, so I came up with an implementation that looks something along the following lines.
<snip>
In case it cannot be converted to the desired destination type a bad_any_cast exception is thrown.
The above code enables boost.any and boost.variant to be used interchangeably as far as boost::get<T> is concerned.
Any thoughts?
Doesn't any_cast do what you are looking for? template<typename T> T any_cast(any &); template<typename T> T any_cast(const any &); template<typename ValueType> const ValueType * any_cast(const any *); template<typename ValueType> ValueType * any_cast(any *); Best, _____________________ Vicente Juan Botet Escribá http://viboes.blogspot.com/