Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] std::fstream problem
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2008-11-06 14:49:56


Christian Henning wrote:
> Adam, thanks a lot. That worked. But when extending to my "real world"
> use case I'm running constantly into troubles. There are still some
> issues with file streams. cout mostly works but ofstream doesn't.
>
> Attached is a file with my use cases. These are very basic usages of
> phoenix and I think they should work.
>
> Thanks,
> Christian
>
> On Wed, Nov 5, 2008 at 3:08 PM, Adam Merz <adammerz_at_[hidden]> wrote:
>> std::for_each(ints.begin(), ints.end(), boost::phoenix::ref(out) << arg1 << ' ');
>>
>> AFAIK, phoenix gives std::cout special treatment in regards to being implicitly
>> captured by reference.
>>

Wouldn't it be easier/more appropriate to provide extraction operator
overload for your point struct and then just:

std::copy( pts.begin()
          , pts.end()
          , std::ostream_iterator<point>(out, "\n"));

The point members could be streamed using transform_iterators.

Jeff


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