Boost logo

Boost Users :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-09-13 11:22:39


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.

This is an extract form Lambda wiki page:

http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Lambda

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

Jaakko


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net