reverse_iterator::operator[]
's return type revisitedSection: 24.5.1.2 [reverse.iterator], 24.5.1.6 [reverse.iter.elem] Status: New Submitter: Robert Haberlach Opened: 2016-02-28 Last modified: 2021-06-06
Priority: 3
View all other issues in [reverse.iterator].
View all issues with New status.
Discussion:
Issue 386 changed the return type of reverse_iterator::operator[]
to unspecified. However,
as of N3066, the return type of a random access iterator's operator[]
shall be convertible to reference
;
thus the return type of reverse_iterator::operator[]
should be reference
(and it is in all common
implementations).
reference
instead of unspecified
.
[2021-06-06 Tim syncs wording to current working draft]
Proposed resolution:
This wording is relative to N4885.
Edit 24.5.1.2 [reverse.iterator], class template synopsis, as indicated:
namespace std { template <class Iterator> class reverse_iterator { public: […] using reference = iter_reference_t<Iterator>; […] constexpr referenceunspecifiedoperator[](difference_type n) const; […] }; }
Change 24.5.1.6 [reverse.iter.elem] before p3 as indicated:
constexpr referenceunspecifiedoperator[](difference_type n) const;