
2 Oct
2008
2 Oct
'08
3:05 p.m.
On Thu, Oct 2, 2008 at 3:25 PM, Peter Dimov
Peter Barker: ...
void accept(TheClass& tc) { }
int main() { std::vector
cont; // Compile error - how to dereference _1 ??? std::for_each(cont.begin(),cont.end(),boost::bind(&accept,_1)); }
How can I dereference _1 so I can use the accept function?
With boost::bind, there's no easy way to dereference _1. You'd need
template<class T> T& deref( T* p ) { return *p; }
std::for_each( cont.begin(), cont.end(), boost::bind( accept, boost::bind( deref<TheClass>, _1 ) ) ); Peter,
It's nice to hear the answer from the horses mouth (so to speak)! Regards, Pete