[Boost-bugs] [Boost C++ Libraries] #10514: Cannot copy const sub_range to non-const

Subject: [Boost-bugs] [Boost C++ Libraries] #10514: Cannot copy const sub_range to non-const
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-18 04:25:48


#10514: Cannot copy const sub_range to non-const
----------------------------------------+------------------------
 Reporter: Braden McDaniel <braden@…> | Owner: neilgroves
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost 1.56.0 | Severity: Regression
 Keywords: |
----------------------------------------+------------------------
 The following code does not compile with Visual Studio 2013 using Boost
 1.56.0:
 {{{
 #!c++
 typedef std::vector<int> vec_t;
 typedef boost::sub_range<vec_t> range_t;
 vec_t vec(10);
 range_t r(vec.begin(), vec.end());
 const range_t & r_ref = r;
 range_t v = r_ref;
 }}}
 The following error results:
 {{{
 boost/range/iterator_range_core.hpp(69) : error C2440: 'static_cast' :
 cannot convert from
 'std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>'
 to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>'
         No constructor could take the source type, or constructor overload
 resolution was ambiguous
         c:\build\ng-10.5-x64\API\inc\boost/range/sub_range.hpp(184) : see
 reference to function template instantiation 'IteratorT
 boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>>(const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>
 &)' being compiled
         with
         [
 IteratorT=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
 , ForwardRange=vec_t
         ]
         c:\build\ng-10.5-x64\API\inc\boost/range/sub_range.hpp(187) : see
 reference to function template instantiation 'IteratorT
 boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_begin<const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>>(const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>
 &)' being compiled
         with
         [
 IteratorT=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
 , ForwardRange=vec_t
         ]
         c:\build\ng-10.5-x64\API\inc\boost/range/sub_range.hpp(184) :
 while compiling class template member function
 'boost::sub_range<vec_t>::sub_range(const boost::sub_range<vec_t> &)'
         sub_range_test.cpp(11) : see reference to function template
 instantiation 'boost::sub_range<vec_t>::sub_range(const
 boost::sub_range<vec_t> &)' being compiled
         sub_range_test.cpp(9) : see reference to class template
 instantiation 'boost::sub_range<vec_t>' being compiled
 boost/range/iterator_range_core.hpp(75) : error C2440: 'static_cast' :
 cannot convert from
 'std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<int>>>'
 to 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>'
         No constructor could take the source type, or constructor overload
 resolution was ambiguous
         c:\build\ng-10.5-x64\API\inc\boost/range/sub_range.hpp(186) : see
 reference to function template instantiation 'IteratorT
 boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>>(const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>
 &)' being compiled
         with
         [
 IteratorT=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
 , ForwardRange=vec_t
         ]
         c:\build\ng-10.5-x64\API\inc\boost/range/sub_range.hpp(187) : see
 reference to function template instantiation 'IteratorT
 boost::iterator_range_detail::iterator_range_impl<IteratorT>::adl_end<const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>>(const
 boost::range_detail::sub_range_base<ForwardRange,boost::random_access_traversal_tag>
 &)' being compiled
         with
         [
 IteratorT=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>
 , ForwardRange=vec_t
         ]
 }}}
 So it looks as though having a `const` `sub_range` implies that it uses
 `const_iterator`s, which doesn't seem appropriate.

 Code of this nature compiled using Boost 1.55.0.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10514>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC