Skip to content

Commit 3cfe300

Browse files
authored
Merge 2023-02 LWG Motion 15
P2655R3 common_reference_t of reference_wrapper Should Be a Reference Type
2 parents 79b7a36 + 9d52df8 commit 3cfe300

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

source/meta.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,9 +2121,11 @@
21212121
\item Otherwise, if \tcode{sizeof...(T)} is two, let \tcode{T1} and \tcode{T2}
21222122
denote the two types in the pack \tcode{T}. Then
21232123
\begin{itemize}
2124-
\item If \tcode{T1} and \tcode{T2} are reference types and
2125-
\tcode{\placeholdernc{COMMON-REF}(T1, T2)} is well-formed, then the member
2126-
typedef \tcode{type} denotes that type.
2124+
\item Let \tcode{R} be \tcode{\placeholdernc{COMMON-REF}(T1, T2)}.
2125+
If \tcode{T1} and \tcode{T2} are reference types,
2126+
\tcode{R} is well-formed, and
2127+
\tcode{is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> \&\& is_convertible_v<add_poin\linebreak{}ter_t<T2>, add_pointer_t<R>>} is \tcode{true},
2128+
then the member typedef \tcode{type} denotes \tcode{R}.
21272129

21282130
\item Otherwise, if
21292131
\tcode{basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>,

source/support.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@
588588
#define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono}
589589
#define @\defnlibxname{cpp_lib_chrono_udls}@ 201304L // also in \libheader{chrono}
590590
#define @\defnlibxname{cpp_lib_clamp}@ 201603L // also in \libheader{algorithm}
591+
#define @\defnlibxname{cpp_lib_common_reference}@ 202302L // also in \libheader{type_traits}
592+
#define @\defnlibxname{cpp_lib_common_reference_wrapper}@ 202302L // also in \libheader{functional}
591593
#define @\defnlibxname{cpp_lib_complex_udls}@ 201309L // also in \libheader{complex}
592594
#define @\defnlibxname{cpp_lib_concepts}@ 202207L // also in \libheader{concepts}, \libheader{compare}
593595
#define @\defnlibxname{cpp_lib_constexpr_algorithms}@ 201806L // also in \libheader{algorithm}, \libheader{utility}

source/utilities.tex

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10453,6 +10453,15 @@
1045310453
template<class T>
1045410454
constexpr reference_wrapper<const T> cref(reference_wrapper<T>) noexcept; // freestanding
1045510455

10456+
// \ref{refwrap.common.ref}, \tcode{common_reference} related specializations
10457+
template<class R, class T, template<class> class RQual, template<class> class TQual>
10458+
requires @\seebelow@
10459+
struct basic_common_reference<R, T, RQual, TQual>;
10460+
10461+
template<class T, class R, template<class> class TQual, template<class> class RQual>
10462+
requires @\seebelow@
10463+
struct basic_common_reference<T, R, TQual, RQual>;
10464+
1045610465
// \ref{arithmetic.operations}, arithmetic operations
1045710466
template<class T = void> struct plus; // freestanding
1045810467
template<class T = void> struct minus; // freestanding
@@ -11004,6 +11013,39 @@
1100411013
\tcode{t}.
1100511014
\end{itemdescr}
1100611015

11016+
\rSec3[refwrap.common.ref]{\tcode{common_reference} related specializations}
11017+
11018+
\indexlibraryglobal{basic_common_reference}%
11019+
\begin{codeblock}
11020+
namespace std {
11021+
template<class T>
11022+
constexpr bool @\exposid{is-ref-wrapper}@ = false; // \expos
11023+
11024+
template<class T>
11025+
constexpr bool @\exposid{is-ref-wrapper}@<reference_wrapper<T>> = true;
11026+
11027+
template<class R, class T, class RQ, class TQ>
11028+
concept @\defexposconcept{ref-wrap-common-reference-exists-with}@ = // \expos
11029+
@\exposid{is-ref-wrapper}@<R> &&
11030+
requires { typename common_reference_t<typename R::type&, TQ>; } &&
11031+
@\libconcept{convertible_to}@<RQ, common_reference_t<typename R::type&, TQ>>;
11032+
11033+
template<class R, class T, template<class> class RQual, template<class> class TQual>
11034+
requires (@\exposconcept{ref-wrap-common-reference-exists-with}@<R, T, RQual<R>, TQual<T>> &&
11035+
!@\exposconcept{ref-wrap-common-reference-exists-with}@<T, R, TQual<T>, RQual<R>>)
11036+
struct basic_common_reference<R, T, RQual, TQual> {
11037+
using type = common_reference_t<typename R::type&, TQual<T>>;
11038+
};
11039+
11040+
template<class T, class R, template<class> class TQual, template<class> class RQual>
11041+
requires (@\exposconcept{ref-wrap-common-reference-exists-with}@<R, T, RQual<R>, TQual<T>> &&
11042+
!@\exposconcept{ref-wrap-common-reference-exists-with}@<T, R, TQual<T>, RQual<R>>)
11043+
struct basic_common_reference<T, R, TQual, RQual> {
11044+
using type = common_reference_t<typename R::type&, TQual<T>>;
11045+
};
11046+
}
11047+
\end{codeblock}
11048+
1100711049
\rSec2[arithmetic.operations]{Arithmetic operations}
1100811050

1100911051
\rSec3[arithmetic.operations.general]{General}

0 commit comments

Comments
 (0)