Boost logo

Boost Users :

Subject: Re: [Boost-users] [type_traits]: is_boost_optional?
From: Roland Bock (rbock_at_[hidden])
Date: 2010-09-01 09:00:14


On 2010-09-01 14:13, Roman Perepelitsa wrote:
> 2010/9/1 Roland Bock <rbock_at_[hidden] <mailto:rbock_at_[hidden]>>
>
> 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> {}

Cool, thanks!

Regards,

Roland


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net