Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8617: Surprising/wrong semantics of counting_range
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-21 23:25:09
#8617: Surprising/wrong semantics of counting_range
-------------------------------+------------------------
Reporter: pbazant@⦠| Owner: neilgroves
Type: Bugs | Status: assigned
Milestone: To Be Determined | Component: range
Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords: range
-------------------------------+------------------------
Comment (by marc.glisse@â¦):
Replying to [comment:1 nathanridge]:
> I confess I find it surprising that an overload of counting_range() that
takes a range exists at all.
>
> I agree that constructing a counting range from the first and last
values of a range seems arbitrary, but constructing a counting range from
the begin and end *iterator* of a range seems pointless (how would the
resulting range be different from the original one?).
It should be the reciprocal of {{{adaptors::indirect}}}. In a range for
loop, there is an implicit iterator {{{iter}}} going from begin to end,
and you get {{{*iter}}} for each element. With indirect, you get
{{{**iter}}}. With counting_range (constructed from iterators, because the
constructor from a range is too weird), you get {{{iter}}} (not
dereferenced). It can be extremely useful and should be available in boost
adaptors with the usual {{{|}}} syntax and a clearer name. This is a
documented use of {{{counting_iterator}}}.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8617#comment:3> 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:15 UTC