Created on 2023-01-25.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4928.
Modify [iterator.synopsis], header <iterator> synopsis, as indicated:
#include <compare> // see [compare.syn] #include <concepts> // see [concepts.syn] namespace std { […] template<class T, common_with<T> U> requires input_iterator<common_type_t<T, U>> struct common_type<basic_const_iterator<T>, U> { // freestanding using type = basic_const_iterator<common_type_t<T, U>>; }; template<class T, common_with<T> U> requires input_iterator<common_type_t<T, U>> struct common_type<U, basic_const_iterator<T>> { // freestanding using type = basic_const_iterator<common_type_t<T, U>>; }; template<class T, common_with<T> U> requires input_iterator<common_type_t<T, U>> struct common_type<basic_const_iterator<T>, basic_const_iterator<U>> { // freestanding using type = basic_const_iterator<common_type_t<T, U>>; }; […] }
[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP. ]
[ Issaquah 2023-02-07; LWG ]
Move to Immediate for C++23
[ 2023-02-06; Jonathan provides improved wording based on Casey's suggestion during the prioritization poll. ]
To make basic_const_iterator compatible with its unwrapped iterators, the standard defines the following common_type specialization:
template<class T, common_with<T> U> struct common_type<basic_const_iterator<T>, U> { using type = basic_const_iterator<common_type_t<T, U>>; };
For type U, when it shares a common type with the unwrapped type T of basic_const_iterator, the common type of both is basic_const_iterator of the common type of T and U.
However, since this specialization only constrains U and T to have a common type, this allows U to be any type that satisfies such requirement, such as optional<T>, in which case computing the common type of both would produce a hard error inside the specialization, because basic_const_iterator requires the template parameter to be input_iterator, while optional clearly isn't.Previous resolution [SUPERSEDED]:
This wording is relative to N4928.
Modify [iterator.synopsis], header <iterator> synopsis, as indicated:
#include <compare> // see [compare.syn] #include <concepts> // see [concepts.syn] namespace std { […] template<class T, common_with<T> U> requires input_iterator<U> struct common_type<basic_const_iterator<T>, U> { // freestanding using type = basic_const_iterator<common_type_t<T, U>>; }; template<class T, common_with<T> U> requires input_iterator<U> struct common_type<U, basic_const_iterator<T>> { // freestanding using type = basic_const_iterator<common_type_t<T, U>>; }; […] }
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2023-02-13 11:31:32 | admin | set | messages: + msg13394 |
2023-02-13 11:31:32 | admin | set | status: immediate -> wp |
2023-02-07 18:08:09 | admin | set | messages: + msg13287 |
2023-02-07 18:08:09 | admin | set | status: new -> immediate |
2023-02-06 16:59:09 | admin | set | messages: + msg13274 |
2023-01-28 13:24:36 | admin | set | messages: + msg13224 |
2023-01-25 00:00:00 | admin | create |