Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range, Phoenix] What am I missing...
From: Michel Morin (mimomorin_at_[hidden])
Date: 2013-03-15 11:23:51


Robert Jones wrote:
> 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

This is because dereferencing `reverse_iterator` of `counting_iterator`
makes a reference to a dead temporary. See #2640
  https://svn.boost.org/trac/boost/ticket/2640

Use `irange( 1, 5 )` instead.

Regards,
Michel


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