1 Sep
2004
1 Sep
'04
7:11 p.m.
Maximilian Wilson wrote:
I am getting another compiler error when trying to use the lambda library. Current experiment is string extraction. I'm trying to create a lambda(x) that pushes any char passed to it onto a particular string.
string s2; void (std::string::*ft)(char) = &std::string::push_back; // extract function pointer because push_back is overloaded char c = 'n'; bind<void>(ft, var(s2), _1, 1)(c);
bind( ft, var(s2), _1 )( c ); ft has two arguments, 'this' and a char. No need for the trailing '1'. Try (s2 += _1)( c ); too.