Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range, Phoenix] What am I missing...
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2017-04-24 19:04:31


On 15 March 2013 at 14:51, Robert Jones <robertgbjones_at_[hidden]> wrote:

> Hi Folks
>
> Can anyone explain the output of this program...
>
> #include <iostream>
> #include <boost/range/algorithm/copy.hpp>
> #include <boost/range/counting_range.hpp>
> #include <boost/range/adaptor/reversed.hpp>
> #include <boost/range/adaptor/transformed.hpp>
> #include <boost/phoenix/bind/bind_function.hpp>
> #include <boost/phoenix/core/argument.hpp>
>
>
> int f( int i ) { return i * 2; }
>
> int main( )
> {
> using boost::adaptors::reversed;
> using boost::adaptors::transformed;
> using boost::counting_range;
> using boost::copy;
> using boost::phoenix::arg_names::_1;
>
> copy( counting_range( 1, 5 ) | reversed | transformed( f ),
> std::ostream_iterator<int>( std::cout, " " ) );
> std::cout << std::endl;
>
> copy( counting_range( 1, 5 ) | reversed | transformed( bind( f, _1 ) ),
> std::ostream_iterator<int>( std::cout, " " ) );
> std::cout << std::endl;
> }
>
> Which is...
>
> 8 6 4 2
> 1768406272 1768406272 1768406272 1768406272
>
> I'm using Gcc 4.6.2 & Boost 1.53
>
> Thx All.
>

Michel Morin was long ago kind enough to diagnose this problem as being due
to https://svn.boost.org/trac/boost/ticket/2640
which is about whether iterators may and should own their referents, but my
trac-foo is not quite up to being certain
whether this was ever fixed or indeed could or should be fixed.

I'd appreciate a quick sentence confirming the current situation.

Thx, Rob.



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