Re: [Boost-bugs] [Boost C++ Libraries] #7630: Range adaptors do not play nicely with range-based for loops

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7630: Range adaptors do not play nicely with range-based for loops
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-05 12:24:58


#7630: Range adaptors do not play nicely with range-based for loops
--------------------------------+-------------------------------------------
  Reporter: gromer@… | Owner: neilgroves
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: range
   Version: Boost 1.51.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------+-------------------------------------------

Comment (by roman.perepelitsa@…):

 There is one problem with the proposed solution: return types for all
 range adaptors are documented. For example, both vec | reversed and and
 vector<int>() | reversed are specified to have type
 reversed_range<vector<int>>, although in the first case the adaptor should
 store just a reference to the vector and in the second case it should have
 the vector stored by value. This can be done by storing
 variant<vector<int>*, vector<int>> in reversed_range<vector<int>>, but it
 has space and performance overhead.

 If return types of range adaptors weren't specified, the problem would not
 exist because vec | reversed and and vector<int>() | reversed could have
 different types, each implemented with zero overhead. This is a cleaner
 design, because specific types of the adaptors aren't of much use and can
 always be deduced with decltype, auto or even erased. Unfortunately, this
 would be a breaking change.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7630#comment:2>
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:11 UTC