|
Boost Users : |
Subject: Re: [Boost-users] [type_traits]: is_boost_optional?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-09-01 10:39:00
Zitat von Roland Bock <rbock_at_[hidden]>:
> On 2010-09-01 15:30, Stefan Strasser wrote:
>> Zitat von Roland Bock <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&);
>>
>> 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_{};
>
> cerr << is_boost_optional<boost::optional<int> >::value << endl;
>
> yields: 0
> expected: 1
>
??
http://boost.codepad.org/2xsgt6AH
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