Created on 2021-04-23.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [common.iter.nav] as indicated:
decltype(auto) operator++(int);-4- Preconditions: holds_alternative<I>(v_) is true.
-5- Effects: If I models forward_iterator, equivalent to:common_iterator tmp = *this; ++*this; return tmp;Otherwise, if requires (I& i) { { *i++ } -> can-reference; } is true or constructible_from<iter_value_t<I>, iter_reference_t<I>> && move_constructible<iter_value_t<I>> is false, equivalent to:
return get<I>(v_)++;Otherwise, equivalent to:
postfix-proxy p(**this); ++*this; return p;where postfix-proxy is the exposition-only class:
class postfix-proxy { iter_value_t<I> keep_; postfix-proxy(iter_reference_t<I>&& x) : keep_(std::moveforward<iter_reference_t<I>>(x)) {} public: const iter_value_t<I>& operator*() const { return keep_; } };
[ 2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-05-17; Reflector poll ]
Set status to Tentatively Ready after five votes in favour during reflector poll.
[ 2021-05-10; Reflector poll ]
Set status to Tentatively Ready after five votes in favour during reflector poll.
P2259R1 modeled common_iterator::operator++(int)'s postfix-proxy class on the existing proxy class used by common_iterator::operator->, but in doing so it overlooked two differences:
operator->'s proxy is only used when iter_reference_t<I> is not a reference type; this is not the case for postfix-proxy;
operator-> returns a prvalue proxy, while operator++'s postfix-proxy is returned by (elidable) move, so the latter needs to require iter_value_t<I> to be move_constructible.
The proposed wording has been implemented and tested.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-06-07 16:58:04 | admin | set | messages: + msg11910 |
2021-06-07 16:58:04 | admin | set | status: voting -> wp |
2021-05-26 21:11:22 | admin | set | status: ready -> voting |
2021-05-17 12:23:56 | admin | set | messages: + msg11806 |
2021-05-10 16:28:00 | admin | set | messages: + msg11796 |
2021-05-10 16:28:00 | admin | set | status: new -> ready |
2021-04-24 17:14:28 | admin | set | messages: + msg11786 |
2021-04-23 00:00:00 | admin | create |