On 15 March 2013 at 14:51, Robert Jones
Hi Folks
Can anyone explain the output of this program...
#include <iostream> #include
#include #include #include #include #include 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.