From 9d52df8b9da721a7cbbd20c670c0f3af6e4d6c1d Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Thu, 16 Feb 2023 15:38:14 -0800 Subject: [PATCH] P2655R3 common_reference_t of reference_wrapper Should Be a Reference Type [refwrap.common.ref] Enclose code in namespace std for consistency. --- source/meta.tex | 8 +++++--- source/support.tex | 2 ++ source/utilities.tex | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index 90b03b1fbb..917869e651 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2121,9 +2121,11 @@ \item Otherwise, if \tcode{sizeof...(T)} is two, let \tcode{T1} and \tcode{T2} denote the two types in the pack \tcode{T}. Then \begin{itemize} - \item If \tcode{T1} and \tcode{T2} are reference types and - \tcode{\placeholdernc{COMMON-REF}(T1, T2)} is well-formed, then the member - typedef \tcode{type} denotes that type. + \item Let \tcode{R} be \tcode{\placeholdernc{COMMON-REF}(T1, T2)}. + If \tcode{T1} and \tcode{T2} are reference types, + \tcode{R} is well-formed, and + \tcode{is_convertible_v, add_pointer_t> \&\& is_convertible_v, add_pointer_t>} is \tcode{true}, + then the member typedef \tcode{type} denotes \tcode{R}. \item Otherwise, if \tcode{basic_common_reference, remove_cvref_t, diff --git a/source/support.tex b/source/support.tex index a3cfe4057d..8c68f16620 100644 --- a/source/support.tex +++ b/source/support.tex @@ -588,6 +588,8 @@ #define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono} #define @\defnlibxname{cpp_lib_chrono_udls}@ 201304L // also in \libheader{chrono} #define @\defnlibxname{cpp_lib_clamp}@ 201603L // also in \libheader{algorithm} +#define @\defnlibxname{cpp_lib_common_reference}@ 202302L // also in \libheader{type_traits} +#define @\defnlibxname{cpp_lib_common_reference_wrapper}@ 202302L // also in \libheader{functional} #define @\defnlibxname{cpp_lib_complex_udls}@ 201309L // also in \libheader{complex} #define @\defnlibxname{cpp_lib_concepts}@ 202207L // also in \libheader{concepts}, \libheader{compare} #define @\defnlibxname{cpp_lib_constexpr_algorithms}@ 201806L // also in \libheader{algorithm}, \libheader{utility} diff --git a/source/utilities.tex b/source/utilities.tex index 1043ee8e9b..0a3004413c 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -10453,6 +10453,15 @@ template constexpr reference_wrapper cref(reference_wrapper) noexcept; // freestanding + // \ref{refwrap.common.ref}, \tcode{common_reference} related specializations + template class RQual, template class TQual> + requires @\seebelow@ + struct basic_common_reference; + + template class TQual, template class RQual> + requires @\seebelow@ + struct basic_common_reference; + // \ref{arithmetic.operations}, arithmetic operations template struct plus; // freestanding template struct minus; // freestanding @@ -11004,6 +11013,39 @@ \tcode{t}. \end{itemdescr} +\rSec3[refwrap.common.ref]{\tcode{common_reference} related specializations} + +\indexlibraryglobal{basic_common_reference}% +\begin{codeblock} +namespace std { + template + constexpr bool @\exposid{is-ref-wrapper}@ = false; // \expos + + template + constexpr bool @\exposid{is-ref-wrapper}@> = true; + + template + concept @\defexposconcept{ref-wrap-common-reference-exists-with}@ = // \expos + @\exposid{is-ref-wrapper}@ && + requires { typename common_reference_t; } && + @\libconcept{convertible_to}@>; + + template class RQual, template class TQual> + requires (@\exposconcept{ref-wrap-common-reference-exists-with}@, TQual> && + !@\exposconcept{ref-wrap-common-reference-exists-with}@, RQual>) + struct basic_common_reference { + using type = common_reference_t>; + }; + + template class TQual, template class RQual> + requires (@\exposconcept{ref-wrap-common-reference-exists-with}@, TQual> && + !@\exposconcept{ref-wrap-common-reference-exists-with}@, RQual>) + struct basic_common_reference { + using type = common_reference_t>; + }; +} +\end{codeblock} + \rSec2[arithmetic.operations]{Arithmetic operations} \rSec3[arithmetic.operations.general]{General}