Re: [Boost-bugs] [Boost C++ Libraries] #10422: Counting Iterator return-type causes lifetime issues

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10422: Counting Iterator return-type causes lifetime issues
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-29 17:24:14


#10422: Counting Iterator return-type causes lifetime issues
-------------------------------+------------------------------
  Reporter: neilgroves | Owner: jeffrey.hellrung
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: iterator
   Version: Boost 1.56.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+------------------------------

Comment (by neilgroves):

 My personal view is that we should ensure we have considered alternative
 solutions since simply making the counting_iterator compliant will:
 1. Break existing code without obvious solutions for clients of
 counting_iterator
 2. Severely degrade performance of many STL algorithms due to degredation
 to the input iterator category.

 I think it is worth considering adopting the same solution as has been
 chosen in Boost.Iterator detail/int_iterator. This returns by value and
 claims to be a std random_access_iterator. This does potentially
 practically go wrong if an algorithm uses auto&. I think returning by
 const value_type would ensure that the lifetime extension works. I believe
 this only leaves theoretical cases where this would go wrong by classes
 squirelling away a reference. I don't think this is of practical
 significance since there are very few assumptions one can make about the
 lifetime of the reference without knowing about the underlying
 container/sequence.

 It is probably worth looking at the experience users have had with
 int_iterator.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10422#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:16 UTC