
1 Sep
2010
1 Sep
'10
7:30 a.m.
Zitat von Roland Bock <rbock@eudoxos.de>:
Hi,
is there something in Boost.TypeTraits (or somewhere else) that allows me to check if a type is a boost::optional?
I'd like to do something like this:
template<typename T> typename enable_if<is_boost_optional<T> >, T::value_type>::type foo(const T&);
there is nothing in type traits, but you can easily check for a specific (template) type: template<typename T> struct is_optional : mpl::false_{}; template<typename T> struct is_optional<optional<T> > : mpl::true_{}; I don't see why you can't use an overload for boost::optional in the first place though: typename optional<T>::value_type foo(optional<T> const &);