C
ckwood
Hi, I was wondering if there was a good way to insert a given member
varaible from a struct into a another container using the boost
framework:
struct SS {
int a,b;
};
vector<SS> v;
//...
set<int> s;
for_each(v.begin(), v.end(), bind( &set<unsigned>::insert, s, (_1 ->*
&SS::a) ));
Is there a better solution?
the easy/obvious soln is:
for(unsigned i =0; i < v.size(); i++) { s.insert(v.a); }
Thanks,
Cameron
varaible from a struct into a another container using the boost
framework:
struct SS {
int a,b;
};
vector<SS> v;
//...
set<int> s;
for_each(v.begin(), v.end(), bind( &set<unsigned>::insert, s, (_1 ->*
&SS::a) ));
Is there a better solution?
the easy/obvious soln is:
for(unsigned i =0; i < v.size(); i++) { s.insert(v.a); }
Thanks,
Cameron