Re: [Boost-users] Using boost::format with Lambda expressions
Jaakko Jarvi (jajarvi@cs.indiana.edu) wrote:
Lambda and format don't play well together, I noticed :( Here's a code that works however, with some explanation. Not pretty.
Best, Jaakko
...
format f("%-10s|") ; for_each(Foos.begin(), Foos.end(), cout << ret
(var(f) % bind(&foo::name, _1))); }
// format defines operator% as a member, which takes precedence over // % defined by lambda. Therefore one must make the format object to // be a lambda functor. var does that. // Var, however, cannot take a temporary object (it holds a reference to // the wrapped object). That's why the variable f. // ret
informs lambda about the return type of formats % operator.
OK, that is just what I was looking for, thanks!!! I tried all of those things but not in the right combination. Is there any resources (i.e. example programs or additional documentation) available for the lambda library. I have read through the test code already. Thanks,
OK, that is just what I was looking for, thanks!!! I tried all of those things but not in the right combination. Is there any resources (i.e. example programs or additional documentation) available for the lambda library. I have read through the test code already.
Other than the Boost docs, not all that much. There's the Boost Wiki, which contains a few tips and tricks:
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl? Lambda_Library_Pages
You might want to add this issue ? Best, Jaakko
participants (2)
-
Jaakko Järvi
-
Shawn Church