|
Boost : |
From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2003-11-20 04:02:34
John Torjo wrote:
> Hi all,
>
> How is boost::mpl::select1st<> supposed to be used?
Like any other metafunction I guess.
> I want something in the lines of selecting the first item from a pair.
>
> Something like:
> std::map< std::string, int> c;
> std::vector<std::string> v;
>
> // copy all the keys into v
> std::copy( c.begin(), c.end(),
> boost::bind<std::string>( select1st(), std::back_inserter(v));
>
> Can select1st be used, or is there some other utility function? Thanks.
This is a compile time equivalent of your code:
typedef mpl::vector<
mpl::pair<.., ..>
, mpl::pair<.., ..>
, ...
> c;
typedef mpl::transform<
c
, mpl::select1st<>
>::type v;
HTH,
-- Daniel Wallin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk