[range]slicing any_range
Hello,
I'm using the Boost.Range library (Version:1.55.0). When I use
any_range with sliced adaptor, slicing operation doesn't return. Is my
code something wrong? If it is a bug, I will create a ticket.
Here is the minimized code that reproduces the situation:
#include <vector>
#include <iostream>
#include <cassert>
#include
I analyzed my program on the following environment: g++ 4.8.2 Linux archboltz 3.12.4-1-ARCH #1 SMP PREEMPT Sun Dec 8 21:18:00 CET 2013 x86_64 GNU/Linux In the file iterator_range_core.hpp , std::advance() is called. The type of BOOST_DEDUCED_TYPENAME range_iterator<Range>::type is boost::iterator_facade< boost::range_detail::any_iterator< int, boost::random_access_traversal_tag, int, long, boost::any_iterator_buffer<64ul>
, int, boost::random_access_traversal_tag, int, long
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME
range_iterator<Range>::type >
make_range_impl( Range& r,
BOOST_DEDUCED_TYPENAME
range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME
range_difference<Range>::type advance_end )
{
//
// Not worth the effort
//
//if( advance_begin == 0 && advance_end == 0 )
// return make_iterator_range( r );
//
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
new_begin = boost::begin( r ),
new_end = boost::end( r );
std::advance( new_begin, advance_begin );
std::advance( new_end, advance_end );
return make_iterator_range( new_begin, new_end );
}
When std::advance() is called, it dispatched to the InputIterator
overloading version of __advance(). My expectation was that dispatched
to the RandomAccessIterator overloading version of __advance().
stl_iterator_base_funcs.h:121
template
Hello,
I'm using the Boost.Range library (Version:1.55.0). When I use any_range with sliced adaptor, slicing operation doesn't return. Is my code something wrong? If it is a bug, I will create a ticket.
Here is the minimized code that reproduces the situation:
#include <vector> #include <iostream> #include <cassert> #include
#include typedef boost::any_range
int_range; int main() { std::vector<int> v; v.push_back(0); v.push_back(1); v.push_back(2); { // works fine std::cout << "slice vector" << std::endl; int_range ir1 = v | boost::adaptors::sliced(0,2); std::cout << "slice vector finished" << std::endl; assert(ir1[0] == 0); assert(ir1[1] == 1); assert(ir1.size() == 2); } { int_range ir2(v); std::cout << "slice any_range" << std::endl; int_range ir3 = ir2 | boost::adaptors::sliced(0,2); // never return... std::cout << "slice any_range finished" << std::endl; assert(ir3[0] == 0); assert(ir3[1] == 1); assert(ir3.size() == 2); } }
Takatoshi Kondo
On Tue, Dec 24, 2013 at 8:48 PM, Takatoshi Kondo
typedef boost::any_range
int_range;
I realized the problem in my code. int_range doesn't support a
reference. It should be
typedef boost::any_range
participants (1)
-
Takatoshi Kondo