2010/9/1 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&);

You can use is_instance_of from lambda library (see boost/lambda/detail/is_instance_of.hpp). It's not part of public interface though, so use it on your own risk.

  template <class T>
  struct is_boost_optional : boost::lambda::is_instance_of_1<T, boost::optional> {}

Roman Perepelitsa.