|
Boost Users : |
From: Christian Henning (chhenning_at_[hidden])
Date: 2007-04-11 14:44:06
I cannot figure out how to copy a vector to another vector and calling
a member function. Please consider the following example.
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <boost/bind.hpp>
using namespace std;
using namespace boost;
class A
{
public:
A( const string& name ) : _name( name ) {}
const string& name() const { return _name; }
private:
string _name;
};
int _tmain(int argc, _TCHAR* argv[])
{
vector<A> as;
as.push_back( A( "A" ));
as.push_back( A( "B" ));
vector<string> ss;
// how to call A::name for each A????
copy( as.begin()
, as.end()
, back_inserter( ss ));
return 0;
}
I'm sure it's very easy, but I don't see right now.
Thanks,
Christian
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