On Fri, 2002-09-13 at 12:22, Jaakko Jarvi wrote:
Hi Ken,
for_each(ell.begin(), ell.end(), cout << _1 << endl);
Any suggestions? I am aware that I can replace endl by '\n' and get a compilable program. I worry that this problem extends to other manipulators...
It's not a bug, just an unfortunate restriction.
Thanks for the quick response.
Example: endl is not now allowed in std::cout statements in a Lambda expression. '\n' has to be used instead.
-- This is because the old style streams were not templates and the new style ones are. Also, endl has been changed from a non-template function to a template function and one cannot take the address of a function template (withtout instantiated it at the same time. For example, in _1 << endl, the library does not know what the type of the stream that later is substituted for _1 will be. -- Jaakko Jarvi
So if I explicitly list the template parameters, does it work? Hmmm...
No, this doesn't work:
for_each(ell.begin(), ell.end(),
cout << _1 << endl