#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
struct Foo
{
int i;
double d;
Foo(int i, double d) :
i(i),
d(d)
{}
int getI() const { return i; }
};
int main()
{
vector<Foo> v;
v.push_back(Foo(1, 2.0));
v.push_back(Foo(5, 3.0));
vector<int> is;
transform(v.begin(), v.end(), back_inserter(is), mem_fun_ref(&Foo::getI));
return 0;
}
Is there a cleaner way to access a member variable then then using a member function like I have above? I know how to do it using tr1::bind, but I need to have C++03 compliant code without boost.