Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-09 23:05:17


Daniel Frey <d.frey_at_[hidden]> writes:

> On Thu, 09 Jan 2003 19:28:17 +0100, David Abrahams wrote:
>
>> typedef mpl::vector<bool,int,double,string> legal_types;
>> BOOST_STATIC_ASSERT((mpl::contains<legal_types,T>::value));
>
> Now that's elegant! I think I should have a look at the MPL soon :))
> One question: 'contains' seems to have the problem that it's not very
> obvious whether it takes the 'vector' as first or second argument.
>
> Is it possible to add a "member function" like this:
>
> typedef mpl::vector< bool, int, double, std::string > legal_types;
> BOOST_STATIC_ASSERT( legal_types::contains< T >::value );

Possible but not desirable, IMO. Contains is a generalized sequence
algorithm like std::find.

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk