Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2007-12-05 12:38:57


chun ping wang skrev:
> Say lets say i have container of regular type T.
>
> And lets say i want to insert them into ptr_vector by getting the keys.
>
> template< typename MapType, typename OutputIterator >
> OutputIterator getKeys(const MapType& map, OutputIterator out )
> {
> typedef typename MapType::value_type map_type;
> typedef typename OutputIterator::value_type out_type;
> std::for_each(map.begin(), map.end(),
> boost::lambda::var(*out)++ =
>
> boost::lambda::construct<out_type>(boost::lambda::bind(&map_type::first,
> boost::lambda::_1))
> );
> return out;
> }
>
> Is it possble to do this. Assuming outputiterator is implemented for
> ptr_vector.

I guess you post the code because it does not work?

Isn't it simpler just to write

typedef typename MApType::const_iterator i = m.begin(), e = m.end();
for( ; i 1= e; ++i )
    *out++ = i->first;

?

-Thorsten


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