Skip to content
Open
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
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
#define @\defnlibxname{cpp_lib_complex_udls}@ 201309L // also in \libheader{complex}
#define @\defnlibxname{cpp_lib_concepts}@ 202207L
// freestanding, also in \libheader{concepts}, \libheader{compare}
#define @\defnlibxname{cpp_lib_constant_wrapper}@ 202603L // freestanding, also in \libheader{utility}
#define @\defnlibxname{cpp_lib_constant_wrapper}@ 202606L // freestanding, also in \libheader{utility}
#define @\defnlibxname{cpp_lib_constexpr_algorithms}@ 202306L // also in \libheader{algorithm}, \libheader{utility}
#define @\defnlibxname{cpp_lib_constexpr_atomic}@ 202411L // also in \libheader{atomic}
#define @\defnlibxname{cpp_lib_constexpr_bitset}@ 202207L // also in \libheader{bitset}
Expand Down
45 changes: 9 additions & 36 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@
void observable_checkpoint() noexcept;

// \ref{const.wrap.class}, class template \tcode{constant_wrapper}
template<class T>
struct @\exposidnc{cw-fixed-value}@; // \expos

template<@\exposidnc{cw-fixed-value}@ X, class = typename decltype(X)::@\exposid{type}@>
template<auto X, class = decltype(X)>
struct constant_wrapper;

template<class T>
Expand All @@ -110,7 +107,7 @@

struct @\exposidnc{cw-operators}@; // \expos

template<@\exposid{cw-fixed-value}@ X>
template<auto X>
constexpr auto @\libglobal{cw}@ = constant_wrapper<X>{};

// \ref{intseq}, compile-time integer sequences%
Expand Down Expand Up @@ -754,23 +751,6 @@

\begin{codeblock}
namespace std {
template<class T>
struct @\exposidnc{cw-fixed-value}@ { // \expos
using @\exposidnc{type}@ = T; // \expos
constexpr @\exposidnc{cw-fixed-value}@(@\exposidnc{type}@ v) noexcept : @\exposidnc{data}@(v) {}
T @\exposidnc{data}@; // \expos
};

template<class T, size_t Extent>
struct @\exposidnc{cw-fixed-value}@<T[Extent]> { // \expos
using @\exposidnc{type}@ = T[Extent]; // \expos
constexpr @\exposidnc{cw-fixed-value}@(T (&arr)[Extent]) noexcept;
T @\exposidnc{data}@[Extent]; // \expos
};

template<class T, size_t Extent>
@\exposidnc{cw-fixed-value}@(T (&)[Extent]) -> @\exposidnc{cw-fixed-value}@<T[Extent]>; // \expos

struct @\exposidnc{cw-operators}@ { // \expos
// unary operators
template<@\exposconcept{constexpr-param}@ T>
Expand Down Expand Up @@ -914,11 +894,11 @@
-> constant_wrapper<(T::value >>= R::value)> { return {}; }
};

template<@\exposid{cw-fixed-value}@ X, class>
template<auto X, class T>
struct @\libglobal{constant_wrapper}@ : @\exposid{cw-operators}@ {
static constexpr const auto & value = X.@\exposid{data}@;
static constexpr decltype(auto) value = (X);
using type = constant_wrapper;
using value_type = decltype(X)::@\exposid{type}@;
using value_type = decltype(X);

template<@\exposconcept{constexpr-param}@ R>
constexpr auto operator=(R) const noexcept
Expand All @@ -943,8 +923,11 @@
that are passed as arguments to constexpr functions to be used in constant expressions.

\pnum
If a specialization of \tcode{constant_wrapper} is instantiated with a type \tcode{T}
such that \tcode{is_same_v<T, value_type>} is \tcode{false},
the program is ill-formed.
\begin{note}
The unnamed second template parameter to \tcode{constant_wrapper} is present
The second template parameter to \tcode{constant_wrapper} is present
to aid argument-dependent lookup\iref{basic.lookup.argdep}
in finding overloads for which \tcode{constant_wrapper}'s wrapped value is a suitable argument,
but for which the \tcode{constant_wrapper} itself is not.
Expand Down Expand Up @@ -982,16 +965,6 @@
\end{codeblock}
\end{example}

\begin{itemdecl}
constexpr @\exposid{cw-fixed-value}@(T (&arr)[Extent]) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initialize elements of \exposid{data} with corresponding elements of \tcode{arr}.
\end{itemdescr}

\indexlibrarymember{operator()}{constant_wrapper}%
\begin{itemdecl}
template<class... Args>
Expand Down
Loading