Andre Poenitz <[EMAIL PROTECTED]> writes:

| > |         vector<string> names;
| > |         std::copy(family.begin(), family.end(),
| > |                   back_inserter(push_back_first(names)));
| > 
| > And this will work equally well with any container that implements
| > push_back not just vectors or constainers that implement operator[]
| 
| And the transform will work on any output iterator. Like ostream_iterator
| or pointer in an array. Aetsch ;-)

You are right...

template<class Pair>
struct firster {
        typedef typename Pair::first_type first_type;
        typedef typename Pair::second_type second_type;
        first_type const & operator()(Pair const & p) const {
                return p.first;
        }
};

vector<string> names;
std::transform(family.begin(), family.end(),
               back_inserter(names), firster<Family::value_type>());

        Lgb

Reply via email to