Boost logo

Boost Users :

From: Richard_Cox_at_[hidden]
Date: 2005-02-05 04:54:22


On Friday, February 04, 2005 5:47 PM Kevin Wheatley wrote:
>
> Richard_Cox_at_[hidden] wrote:
> >
> > The program below outputs
> >
> > String: <First string> Second string> Fourth string> Fifth string>
> >
> > All but the first "<" is missing. Any ideas?
> > std::for_each(coll.begin(), coll.end(), out << gt << _1
> << L"> ");
>
>
> does this work?
>
> std::for_each(coll.begin(), coll.end(), out << var(gt) << _1 << L">
> ");
>
> not sure of the fix, but out << gt associates left to right and is
> evaluated once and has the type of out, you want it lazy evaluated so
> that the whole of the expression is considered as one... see the
> delaying constants and variables section of the lambda documents.
>
> Kevin

Of course, "obvious" now :-(

out << gt

would evaluate returning the wostream which the lambda expression
created from the 2nd and 3rd <<'s then operates on.

Many thanks.

Richard
All opinions are mine and do not represent in any way the position of
Dell Corporation.


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