2188. Reverse iterator does not fully support targets that overload operator&

Section: 27.5.1.3.5 [reverse.iter.opref] Status: C++14 Submitter: Alisdair Meredith Opened: 2012-09-23 Last modified: 2016-02-10

Priority: 1

View all other issues in [reverse.iter.opref].

View all issues with C++14 status.

Discussion:

The specification for reverse_iterator::operator-> returns the address of the object yielded by dereferencing with operator*, but does not have the usual wording about returning the true address of the object. As reverse_iterator requires the adapted iterator have at least the bidirectional iterator category, we know that the returned reference is a true reference, and not a proxy, hence we can use std::addressof on the reference to get the right answer.

This will most likely show itself as an issue with a list or vector of a type with such an overloaded operator, where algorithms are likely to work with a forward iteration, but not with reverse iteration.

[2013-04-20, Bristol]

Resolution: Goes to open now and move to review as soon as Daniel proposes a new wording.

[2014-02-12 Issaquah meeting]

Use std::addressof as the library uses elsewhere, then move as Immediate.

Proposed resolution:

Revise 27.5.1.3.5 [reverse.iter.opref] p1, as indicated:

Returns: addressof&(operator*()).