common_type
and common_reference
have flaws in commonSection: 21.3.8.7 [meta.trans.other] Status: C++23 Submitter: Casey Carter Opened: 2018-08-10 Last modified: 2023-11-22
Priority: 3
View all other issues in [meta.trans.other].
View all issues with C++23 status.
Discussion:
21.3.8.7 [meta.trans.other] p5 characterizes the requirements for
program-defined specializations of common_type
with the sentence:
Such a specialization need not have a member namedtype
, but if it does, that member shall be a typedef-name for an accessible and unambiguous cv-unqualified non-reference typeC
to which each of the typesT1
andT2
is explicitly convertible.
This sentence - which 21.3.8.7 [meta.trans.other] p7 largely duplicates to
specify requirements on program-defined specializations of
basic_common_reference
- has two problems:
The grammar term "typedef-name" is overconstraining; there's no reason to prefer a typedef-name here to an actual type, and
"accessible" and "unambiguous" are not properties of types, they are properties of names and base classes.
While we're here, we may as well strike the unused name C
which
both Note B and Note D define for the type denoted by type
.
[2018-08 Batavia Monday issue prioritization]
Priority set to 3
[2021-06-23; Reflector poll]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4762.
Modify 21.3.8.7 [meta.trans.other] p5 as follows:
-5- Note B: Notwithstanding the provisions of 21.3.3 [meta.type.synop], and pursuant to 16.4.5.2.1 [namespace.std], a program may specialize
common_type<T1, T2>
for typesT1
andT2
such thatis_same_v<T1, decay_t<T1>>
andis_same_v<T2, decay_t<T2>>
are each true. [Note: …] Such a specialization need not have a member namedtype
, but if it does,that member shall be a typedef-name for an accessible and unambiguousthe qualified-idcommon_type<T1, T2>::type
shall denote a cv-unqualified non-reference typeto which each of the typesC
T1
andT2
is explicitly convertible. Moreover, […]
Modify 21.3.8.7 [meta.trans.other] p7 similarly:
-7- Note D: Notwithstanding the provisions of 21.3.3 [meta.type.synop], and pursuant to 16.4.5.2.1 [namespace.std], a program may partially specialize
basic_common_reference<T, U, TQual, UQual>
for typesT
andU
such thatis_same_v<T, decay_t<T>>
andis_same_v<U, decay_t<U>>
are each true. [Note: …] Such a specialization need not have a member namedtype
, but if it does,that member shall be a typedef-name for an accessible and unambiguousthe qualified-idbasic_common_reference<T, U, TQual, UQual>::type
shall denote a typeto which each of the typesC
TQual<T>
andUQual<U>
is convertible. Moreover, […]