Opened 15 years ago

Closed 13 years ago

#1019 closed Bugs (fixed)

iterator_facade::pointer should be the return type of operator-> (DR 445)

Reported by: Niels Dekker Owned by: Dave Abrahams
Milestone: Boost 1.36.0 Component: iterator
Version: Boost 1.34.0 Severity: Problem
Keywords: Cc:

Description

The definition of iterator_facade does not agree with the resolution of Standard Library Defect Report 445, submitted by David Abrahams, 2003-12-09.
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#445

DR 445 is resolved within the current Draft of the Standard, as follows (Iterator traits, section 24.3.1):
iterator_traits<Iterator>::reference
iterator_traits<Iterator>::pointer
shall be defined as the iterator’s reference and pointer types, that is, for an iterator object a, the same type as the type of *a and a->, respectively.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2135.pdf

On the other hand, iterator_facade::pointer is a raw pointer, while iterator_facade::operator->() returns operator_arrow_result::type, which may be a proxy.

To conform to the resolution of DR 445, iterator_facade::pointer should be defined as the return type of operator->(), e.g. (assuming that raw_pointer is the original raw pointer to the value_type):

  typedef typename operator_arrow_result<
      value_type
    , reference
    , raw_pointer
    >::type pointer;

More discussion about this issue:

comp.lang.c++.moderated, Sep 29 2005
Re: iterator dereference requirements
http://groups.google.com/group/comp.lang.c++.moderated/msg/0f332bcd9a911526

comp.std.c++, March/April 2007
What should std::InputIterator<T>::pointer be? [n2193 / n2083]
http://groups.google.com/groups/search?q=%22What+should+std%3A%3AInputIterator%3CT%3E%3A%3Apointer+be%3F%22

comp.std.c++, May 2007
Testing new iterator concepts with ConceptGCC
http://groups.google.com/group/comp.std.c++/tree/browse_frm/thread/9c40ffc2f6394ca0/590e75dfbb993cf6

[I had some e-mail discussion with David Abrahams on this issue as well.]

Change History (4)

comment:1 by Thomas Witt, 15 years ago

Milestone: Boost 1.34.1Boost 1.35.0

Did not make the deadline.

comment:2 by Eric Niebler, 15 years ago

Owner: set to Dave Abrahams

comment:3 by Dave Abrahams, 14 years ago

Status: newassigned

comment:4 by Dave Abrahams, 13 years ago

Resolution: fixed
Status: assignedclosed

(In [57989]) Made sure that iterator_facade's nested ::pointer type is always the same as what's returned from operator->. For input iterators, that wasn't always the case (see operator_arrow_proxy).

Fixes #1019.

Note: See TracTickets for help on using tickets.