Opened 8 years ago

Last modified 8 years ago

#10989 assigned Bugs

strided breaks on impure traversal tags

Reported by: anonymous Owned by: Neil Groves
Milestone: Boost 1.58.0 Component: range
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc:

Description

From http://stackoverflow.com/questions/28280553/boostadaptorsstrided-cannot-be-used-after-boostadaptorstransformed

[...]/boost/1.57.0/include/boost/range/iterator_range_core.hpp:216:20: error: no matching function for call to ‘boost::range_detail::strided_iterator<boost::iterators::transform_iterator<TrivialTrafo, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>, boost::iterators::detail::iterator_category_with_traversal<std::input_iterator_tag, boost::iterators::random_access_traversal_tag> >::strided_iterator(boost::range_detail::strided_iterator<boost::iterators::transform_iterator<TrivialTrafo, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, boost::iterators::use_default, boost::iterators::use_default>, boost::iterators::random_access_traversal_tag>&)’

, m_End(End)

Problem is that make_begin_strided_iterator et al coerce the returned iterator traversal category/tag to a pure traversal tag, which doesn't necessarily agree with the Category passed to iterator_range for the base type. Fix is to use iterators::pure_iterator_traversal.

Change History (3)

comment:1 by Edward Catmur <ed@…>, 8 years ago

Fix:

--- a/include/boost/range/adaptor/strided.hpp +++ b/include/boost/range/adaptor/strided.hpp @@ -603,7 +603,7 @@ namespace boost

template<

class Rng, class Category =

  • typename iterator_traversal<

+ typename iterators::pure_iterator_traversal<

typename range_iterator<Rng>::type

::type

in reply to:  1 comment:2 by Edward Catmur <ed@…>, 8 years ago

Let's try that again.

Fix:

--- a/include/boost/range/adaptor/strided.hpp
+++ b/include/boost/range/adaptor/strided.hpp
@@ -603,7 +603,7 @@ namespace boost
         template<
             class Rng,
             class Category =
-                typename iterator_traversal<
+                typename iterators::pure_iterator_traversal<
                     typename range_iterator<Rng>::type
                 >::type
         >

comment:3 by Neil Groves, 8 years ago

Milestone: To Be DeterminedBoost 1.58.0
Status: newassigned

Thank you very much for your excellent ticket. This was superb. I've applied the change to the develop branch. Once this cycles a few times through the tests I shall merge to master ready for the 1.58 release.

Note: See TracTickets for help on using tickets.