Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] Making my expression less complicated
From: Peter Barker (newbarker_at_[hidden])
Date: 2008-09-05 13:03:42


--- On Fri, 5/9/08, Steven Watanabe <watanabesj_at_[hidden]> wrote:

> From: Steven Watanabe <watanabesj_at_[hidden]>
> Subject: Re: [Boost-users] [lambda] Making my expression less complicated
> To: boost-users_at_[hidden]
> Date: Friday, 5 September, 2008, 5:44 PM
> AMDG
>
> Peter Barker wrote:
> > Hello,
> >
> > In my test program below, I have a container of
> columns and want to output the column headers into a string
> separated by a tab. The lambda expression is looking fairly
> complicated so I wonder if it could be made simpler or if
> there's any other algorithm I should've used to put
> a separator between the elements?
> >
>
> How about,
>
> std::size_t i = 0;
>
> //...
> (
> if_(var(i)++) [ var(outputText) +=
> constant(fieldSeparator) ],
> var(outputText) += bind(&Column::getColumnText,_1)
> )

That's much nicer and works very well, thanks :)

By the way, do you know if there's something in Boost that works like std::ostream_iterator but does what I'm doing - putting the delimiter between the elements, not after each element? Some Googling tells me that there was an "Output Formatter" Boost library submitted with a range_streamer class to do it but the looks like that library was rejected. See http://lists.boost.org/Archives/boost/2004/09/71875.php

Regards,

Pete


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