Re: [Boost-bugs] [Boost C++ Libraries] #8011: iterator_range::size() is not SFINAE-friendly

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8011: iterator_range::size() is not SFINAE-friendly
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-18 06:47:37


#8011: iterator_range::size() is not SFINAE-friendly
---------------------------------------------------------+------------------
  Reporter: Jonathan Wakely <jwakely.boost@…> | Owner: neilgroves
      Type: Feature Requests | Status: new
 Milestone: To Be Determined | Component: range
   Version: Boost 1.52.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------------------+------------------

Comment (by nathanridge):

 Replying to [comment:2 Jonathan Wakely <jwakely.boost@…>]:
> I used to assume each range had a `r.size()` member, but that broke for
 `iterator_range` with non-random access iterators, so now I use
 `std::distance(std::begin(r), std::end(r))`, which is O(n). I would prefer
 to use `r.size()` if it's usable

 Actually, according to section 24.4.4/4 [iterator.operations] of the
 standard, std::distance is O(1) for random-access iterators. So you can
 just always use std::distance.

 In light of this, do you still think there is a use case for what you are
 requesting?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8011#comment:10>
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:12 UTC