Skip to content

Commit ef1752d

Browse files
committed
P3948R1 constant_wrapper is the only tool needed for passing constant expressions via function arguments
Fixes NB FR-019-210 and FR-021-218 (C++26 CD).
1 parent fda5e37 commit ef1752d

1 file changed

Lines changed: 26 additions & 31 deletions

File tree

source/utilities.tex

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@
225225
};
226226
template<size_t I> constexpr in_place_index_t<I> in_place_index{};
227227

228-
// \tcode{constant_arg} argument tag%
229-
\indexlibraryglobal{constant_arg_t}%
230-
\indexlibraryglobal{constant_arg}
231-
template<auto V>
232-
struct constant_arg_t {
233-
explicit constant_arg_t() = default;
234-
};
235-
template<auto V> constexpr constant_arg_t<V> constant_arg{};
236-
237228
// \ref{variant.monostate}, class \tcode{monostate}%
238229
\indexlibraryglobal{monostate}
239230
struct monostate;
@@ -15178,9 +15169,11 @@
1517815169
// \ref{func.wrap.ref.ctor}, constructors and assignment operators
1517915170
template<class F> function_ref(F*) noexcept;
1518015171
template<class F> constexpr function_ref(F&&) noexcept;
15181-
template<auto f> constexpr function_ref(constant_arg_t<f>) noexcept;
15182-
template<auto f, class U> constexpr function_ref(constant_arg_t<f>, U&&) noexcept;
15183-
template<auto f, class T> constexpr function_ref(constant_arg_t<f>, @\cv{}@ T*) noexcept;
15172+
template<auto c, class F> constexpr function_ref(constant_wrapper<c, F>) noexcept;
15173+
template<auto c, class F, class U>
15174+
constexpr function_ref(constant_wrapper<c, F>, U&&) noexcept;
15175+
template<auto c, class F, class T>
15176+
constexpr function_ref(constant_wrapper<c, F>, @\cv{}@ T*) noexcept;
1518415177

1518515178
constexpr function_ref(const function_ref&) noexcept = default;
1518615179
constexpr function_ref& operator=(const function_ref&) noexcept = default;
@@ -15311,21 +15304,27 @@
1531115304

1531215305
\indexlibraryctor{function_ref}%
1531315306
\begin{itemdecl}
15314-
template<auto f> constexpr function_ref(constant_arg_t<f>) noexcept;
15307+
template<auto c, class F> constexpr function_ref(constant_wrapper<c, F> f) noexcept;
1531515308
\end{itemdecl}
1531615309

1531715310
\begin{itemdescr}
15318-
\pnum
15319-
Let \tcode{F} be \tcode{decltype(f)}.
15320-
1532115311
\pnum
1532215312
\constraints
1532315313
\tcode{\exposid{is-invocable-using}<const F\&>} is \tcode{true}.
1532415314

1532515315
\pnum
1532615316
\mandates
15317+
\begin{itemize}
15318+
\item
1532715319
If \tcode{is_pointer_v<F> || is_member_pointer_v<F>} is \tcode{true},
15328-
then \tcode{f != nullptr} is \tcode{true}.
15320+
then \tcode{f.value != nullptr} is \tcode{true}, and
15321+
\item
15322+
if \tcode{ArgTypes} is not an empty pack and
15323+
all types in \tcode{remove_cvref_t<ArgTypes>...}
15324+
satisfy \exposconcept{constexpr-param} then
15325+
\tcode{constant_wrapper<\placeholdernc{INVOKE}(f.value, remove_cvref_t<ArgTypes>::\newline value...)>}
15326+
is not a valid type.
15327+
\end{itemize}
1532915328

1533015329
\pnum
1533115330
\effects
@@ -15341,14 +15340,13 @@
1534115340

1534215341
\indexlibraryctor{function_ref}%
1534315342
\begin{itemdecl}
15344-
template<auto f, class U>
15345-
constexpr function_ref(constant_arg_t<f>, U&& obj) noexcept;
15343+
template<auto c, class F, class U>
15344+
constexpr function_ref(constant_wrapper<c, F> f, U&& obj) noexcept;
1534615345
\end{itemdecl}
1534715346

1534815347
\begin{itemdescr}
1534915348
\pnum
15350-
Let \tcode{T} be \tcode{remove_reference_t<U>} and
15351-
\tcode{F} be \tcode{decltype(f)}.
15349+
Let \tcode{T} be \tcode{remove_reference_t<U>}.
1535215350

1535315351
\pnum
1535415352
\constraints
@@ -15360,7 +15358,7 @@
1536015358
\pnum
1536115359
\mandates
1536215360
If \tcode{is_pointer_v<F> || is_member_pointer_v<F>} is \tcode{true},
15363-
then \tcode{f != nullptr} is \tcode{true}.
15361+
then \tcode{f.value != nullptr} is \tcode{true}.
1536415362

1536515363
\pnum
1536615364
\effects
@@ -15370,27 +15368,24 @@
1537015368
such that
1537115369
\tcode{\placeholder{thunk}(\exposid{bound-entity}, \placeholder{call-args}...)}
1537215370
is expression-equivalent\iref{defns.expression.equivalent} to
15373-
\tcode{invoke_r<R>(f, static_cast<\cv{} T\&>(obj), \placeholder{call-args}...)}.
15371+
\tcode{invoke_r<R>(f.value, static_cast<\cv{} T\&>(obj), \placeholder{call-args}...)}.
1537415372
\end{itemdescr}
1537515373

1537615374
\indexlibraryctor{function_ref}%
1537715375
\begin{itemdecl}
15378-
template<auto f, class T>
15379-
constexpr function_ref(constant_arg_t<f>, @\cv{}@ T* obj) noexcept;
15376+
template<auto c, class F>
15377+
constexpr function_ref(constant_wrapper<c, F> f, @\cv{}@ T* obj) noexcept;
1538015378
\end{itemdecl}
1538115379

1538215380
\begin{itemdescr}
15383-
\pnum
15384-
Let \tcode{F} be \tcode{decltype(f)}.
15385-
1538615381
\pnum
1538715382
\constraints
1538815383
\tcode{\exposid{is-invocable-using}<const F\&, \cv{} T*>} is \tcode{true}.
1538915384

1539015385
\pnum
1539115386
\mandates
1539215387
If \tcode{is_pointer_v<F> || is_member_pointer_v<F>} is \tcode{true},
15393-
then \tcode{f != nullptr} is \tcode{true}.
15388+
then \tcode{f.value != nullptr} is \tcode{true}.
1539415389

1539515390
\pnum
1539615391
\expects
@@ -15405,7 +15400,7 @@
1540515400
such that
1540615401
\tcode{\placeholder{thunk}(\exposid{bound-entity}, \placeholder{call-args}...)}
1540715402
is expression-equivalent\iref{defns.expression.equivalent} to
15408-
\tcode{invoke_r<R>(f, obj, \placeholder{call-args}...)}.
15403+
\tcode{invoke_r<R>(f.value, obj, \placeholder{call-args}...)}.
1540915404
\end{itemdescr}
1541015405

1541115406
\indexlibrarymember{operator=}{function_ref}%
@@ -15419,7 +15414,7 @@
1541915414
\begin{itemize}
1542015415
\item \tcode{T} is not the same type as \tcode{function_ref},
1542115416
\item \tcode{is_pointer_v<T>} is \tcode{false}, and
15422-
\item \tcode{T} is not a specialization of \tcode{constant_arg_t}.
15417+
\item \tcode{T} is not a specialization of \tcode{constant_wrapper}.
1542315418
\end{itemize}
1542415419
\end{itemdescr}
1542515420

0 commit comments

Comments
 (0)