
7 Jan
2007
7 Jan
'07
10:51 p.m.
Server Levent Yilmaz wrote:
As a side discussion, well it is kind of off topic but now that you brought it up, there was a case where I couldn't get away with using member pointers and needed this pointer algebra. I'd appreciate any idea on this. The problem is simple. Take this struct,
struct A { double a[3]; }
For, this I needed to callback, say, a[2]. A callback facility designed with member pointers wouldn't be able to handle this case. Right?
You are right, there is no way to take a member pointer to a[2]. You need int main() { A obj = { 1, 2, 3 }; namespace ll = boost::lambda; boost::function<double(const A&)> f = ll::bind( &A::a, ll::_1 )[ 2 ]; foo( f, obj ); }