Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions source/meta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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<T1>, add_pointer_t<R>> \&\& is_convertible_v<add_poin\linebreak{}ter_t<T2>, add_pointer_t<R>>} is \tcode{true},
then the member typedef \tcode{type} denotes \tcode{R}.

\item Otherwise, if
\tcode{basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>,
Expand Down
2 changes: 2 additions & 0 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
42 changes: 42 additions & 0 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -10453,6 +10453,15 @@
template<class T>
constexpr reference_wrapper<const T> cref(reference_wrapper<T>) noexcept; // freestanding

// \ref{refwrap.common.ref}, \tcode{common_reference} related specializations
template<class R, class T, template<class> class RQual, template<class> class TQual>
requires @\seebelow@
struct basic_common_reference<R, T, RQual, TQual>;

template<class T, class R, template<class> class TQual, template<class> class RQual>
requires @\seebelow@
struct basic_common_reference<T, R, TQual, RQual>;

// \ref{arithmetic.operations}, arithmetic operations
template<class T = void> struct plus; // freestanding
template<class T = void> struct minus; // freestanding
Expand Down Expand Up @@ -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<class T>
constexpr bool @\exposid{is-ref-wrapper}@ = false; // \expos

template<class T>
constexpr bool @\exposid{is-ref-wrapper}@<reference_wrapper<T>> = true;

template<class R, class T, class RQ, class TQ>
concept @\defexposconcept{ref-wrap-common-reference-exists-with}@ = // \expos
@\exposid{is-ref-wrapper}@<R> &&
requires { typename common_reference_t<typename R::type&, TQ>; } &&
@\libconcept{convertible_to}@<RQ, common_reference_t<typename R::type&, TQ>>;

template<class R, class T, template<class> class RQual, template<class> class TQual>
requires (@\exposconcept{ref-wrap-common-reference-exists-with}@<R, T, RQual<R>, TQual<T>> &&
!@\exposconcept{ref-wrap-common-reference-exists-with}@<T, R, TQual<T>, RQual<R>>)
struct basic_common_reference<R, T, RQual, TQual> {
using type = common_reference_t<typename R::type&, TQual<T>>;
};

template<class T, class R, template<class> class TQual, template<class> class RQual>
requires (@\exposconcept{ref-wrap-common-reference-exists-with}@<R, T, RQual<R>, TQual<T>> &&
!@\exposconcept{ref-wrap-common-reference-exists-with}@<T, R, TQual<T>, RQual<R>>)
struct basic_common_reference<T, R, TQual, RQual> {
using type = common_reference_t<typename R::type&, TQual<T>>;
};
}
\end{codeblock}

\rSec2[arithmetic.operations]{Arithmetic operations}

\rSec3[arithmetic.operations.general]{General}
Expand Down