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
25 changes: 0 additions & 25 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5399,31 +5399,6 @@
layout-compatible enumerations\iref{dcl.enum}, or
layout-compatible standard-layout class types\iref{class.mem}.

\pnum
A type is \defn{consteval-only} if it is
\begin{itemize}
\item \tcode{std::meta::info},
\item \cv{}~\tcode{T}, where \tcode{T} is a consteval-only type,
\item a pointer or reference to a consteval-only type,
\item an array of consteval-only type,
\item a function type having a return type or any parameter type that is consteval-only,
\item a class type with any non-static data member having consteval-only type, or
\item a type ``pointer to member of class \tcode{C} of type \tcode{T}'',
where at least one of \tcode{C} or \tcode{T} is a consteval-only type.
\end{itemize}
Every object of consteval-only type shall be
\begin{itemize}
\item
the object associated with a constexpr variable or a subobject thereof,
\item
a template parameter object\iref{temp.param} or a subobject thereof, or
\item
an object whose lifetime begins and ends
during the evaluation of a core constant expression.
\end{itemize}
Every function of consteval-only type shall be
an immediate function\iref{expr.const.imm}.

\rSec2[basic.fundamental]{Fundamental types}

\pnum
Expand Down
4 changes: 1 addition & 3 deletions source/classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4121,9 +4121,7 @@
\indextext{function!virtual|)}

\pnum
A class with an immediate virtual function that overrides
a non-immediate virtual function
shall have consteval-only type\iref{basic.types.general}.
A non-immediate virtual function shall not be overridden by an immediate virtual function.
An immediate virtual function shall not be overridden by
a non-immediate virtual function.

Expand Down
119 changes: 65 additions & 54 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8418,6 +8418,7 @@
A type has \defnadj{constexpr-unknown}{representation} if it
\begin{itemize}
\item is a union,
\item is \tcode{std::meta::type_info},
\item is a pointer or pointer-to-member type,
\item is volatile-qualified,
\item is a class type with a non-static data member of reference type, or
Expand Down Expand Up @@ -8907,58 +8908,55 @@
\rSec2[expr.const.const]{Constant expressions}

\pnum
A \defnadj{constant}{expression} is either
A \defnadj{consteval-only}{value} is either
\begin{itemize}
\item
a glvalue core constant expression $E$ for which
\item a reflection value\iref{basic.fundamental} that is not the null reflection value or
\item a pointer or pointer-to-member that points to an immediate function or to or past the end
of an immediate object.
\end{itemize}

\pnum
An object is an \defnadj{immediate}{object} if its complete object has
\begin{itemize}
\item
$E$ refers to a non-immediate function,
\item
$E$ designates an object \tcode{o}, and
if the complete object of \tcode{o} is of consteval-only type then so is $E$,
\item a constituent value that is consteval-only or
\item a constituent reference that refers to an immediate object or immediate function.
\end{itemize}

\pnum
Every immediate object shall be
\begin{itemize}
\item the object associate with a constexpr variable or a subobject thereof,
\item a template parameter object\iref{temp.param} or a subject thereof, or
\item an object whose lifetime begins and ends during the evaluation of a core constant expression.
\begin{example}
\begin{codeblock}
struct Base { };
struct Derived : Base { std::meta::info r; };
consteval int plus1(int x) { return x + 1; }
template <auto V> struct C {};

consteval const Base& fn(const Derived& derived) { return derived; }
auto a = plus1; // error: immediate object not associated with constexpr variable
constexpr auto b = plus1; // OK
auto c = C<plus1>(); // OK

constexpr Derived obj{.r=^^::}; // OK
constexpr const Derived& d = obj; // OK
constexpr const Base& b = fn(obj); // error: not a constant expression because \tcode{Derived}
// is a consteval-only type but \tcode{Base} is not.
auto d = ^^int; // error: immediate object not associated with constexpr variable
auto e = C<^^char>(); // OK
\end{codeblock}
\end{example}
Each expression $E$ that odr-uses a variable that declares or referes to an immediate object
shall be in an immediate function context; a diagnostic is required only if either
\item the innermost declaration that contains $E$ or
\item the defining declaration of the variable is reachable from the other.
\end{itemize}
or
\item
a prvalue core constant expression whose result object\iref{basic.lval} (if any)
satisfies the following constraints:
\begin{itemize}
\item
each constituent reference refers to an object or a non-immediate function,
\item
no constituent value of scalar type is an indeterminate or erroneous value\iref{basic.indet},
\item
no constituent value of pointer type is a pointer to an immediate function or
an invalid pointer value\iref{basic.compound},
\item
no constituent value of pointer-to-member type designates an immediate function, and
\item
unless the value is of consteval-only type,

\pnum
A core constant expression is a \defnadj{constant}{expression} unless it is a prvalue whose result
object\iref{basic.lval} has a constituent value that is an invalid pointer value\iref{basic.compound}
or is indeterminate or erroneous\iref{basic.indet}

\pnum
A constant expression is an \defnadj{immediate}{constant}{expression} if it is either
\begin{itemize}
\item
no constituent value of pointer-to-member type points to
a direct member of a consteval-only class type,
\item
no constituent value of pointer type points to or past an object
whose complete object is of consteval-only type, and
\item
no constituent reference refers to an object
whose complete object is of consteval-only type.
\end{itemize}
\end{itemize}
\item a glvalue that refers to an immediate object or an immediate function, or
\item a prvalue whose result object (if any) is an immediate object
\end{itemize}
\begin{note}
A glvalue core constant expression
Expand Down Expand Up @@ -9277,12 +9275,29 @@
nor a subexpression of an immediate invocation, and
\begin{itemize}
\item
it is an \grammarterm{id-expression} or \grammarterm{splice-expression}
that designates an immediate function,
it is an immediate constant expression or
\begin{example}
\begin{codeblock}
consteval std::meta::info refl() { return ^^int; }
template <auto F>
constexpr void ex() {
auto x = F();
}
auto p = &ex<refl>; // error: immediate function because F()
// is an immediate constant expression
\end{codeblock}
\end{example}
\item
it is an immediate invocation that is not a constant expression, or
\item
it is of consteval-only type\iref{basic.types.general}.
\begin{example}
\begin{codeblock}
consteval int id(int x) { return x; }
template <auto F>
constexpr auto apply_to(int i) { return F(i); }
auto p = &apply_to<id>; // error: immediate function because F(i)
// is not a constant expression
\end{codeblock}
\end{example}
\end{itemize}

\pnum
Expand All @@ -9304,19 +9319,15 @@
in an immediate-escalating function.

\pnum
An \defnadj{immediate}{function} is a function that is
An \defnadj{immediate}{function} is a function that is either
\begin{itemize}
\item
declared with the \keyword{consteval} specifier,
\item
an immediate-escalating function
whose type is consteval-only\iref{basic.types.general}, or
declared with the \keyword{consteval} specifier, or
\item
an immediate-escalating function \tcode{\placeholder{F}}
whose function body contains either
whose function body contains
\begin{itemize}
\item an immediate-escalating expression or
\item a definition of a non-constexpr variable with consteval-only type
\item an immediate-escalating expression
\end{itemize}
whose innermost enclosing non-block scope
is \tcode{\placeholder{F}}'s function parameter scope.
Expand Down
9 changes: 5 additions & 4 deletions source/meta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,6 @@
\pnum
Reflection functions throw exceptions of type \tcode{meta::exception}
to signal an error.
\tcode{meta::exception} is a consteval-only type.

\indexlibraryctor{exception}%
\begin{itemdecl}
Expand Down Expand Up @@ -5150,7 +5149,9 @@
\end{codeblock}

\pnum
The type \tcode{access_context} is a structural, consteval-only, non-aggregate type.
The type \tcode{access_context} is a structural, non-aggregate type.
A value \tcode{ac} of type \tcode{access_context} is consteval-only if
either \tcode{ac.scope()} or \tcode{ac.designating_class()} is consteval-only.
Two values \tcode{ac1} and \tcode{ac2} of type \tcode{access_context}
are template-argument-equivalent\iref{temp.type}
if \tcode{ac1.scope()} and \tcode{ac2.scope()} are template-argument-equivalent
Expand Down Expand Up @@ -6417,8 +6418,8 @@
\pnum
The classes \tcode{data_member_options}
and \tcode{data_member_options::\exposid{name-type}}
are consteval-only types\iref{basic.types.general},
and are not structural types\iref{temp.param}.
are not structural types\iref{temp.param}.
Values of both types are consteval-only values.

\begin{itemdecl}
template<class T>
Expand Down
2 changes: 1 addition & 1 deletion source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@
\defnxname{cpp_char8_t} & \tcode{202207L} \\ \rowsep
\defnxname{cpp_concepts} & \tcode{202002L} \\ \rowsep
\defnxname{cpp_conditional_explicit} & \tcode{201806L} \\ \rowsep
\defnxname{cpp_consteval} & \tcode{202211L} \\ \rowsep
\defnxname{cpp_consteval} & \tcode{202606L} \\ \rowsep
\defnxname{cpp_constexpr} & \tcode{202406L} \\ \rowsep
\defnxname{cpp_constexpr_dynamic_alloc} & \tcode{201907L} \\ \rowsep
\defnxname{cpp_constexpr_exceptions} & \tcode{202411L} \\ \rowsep
Expand Down
4 changes: 0 additions & 4 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16360,10 +16360,6 @@
\item \tcode{is_trivially_copyable_v<From>} is \tcode{true}.
\end{itemize}

\pnum
\mandates
Neither \tcode{To} nor \tcode{From} are consteval-only types\iref{basic.types.general}.

\pnum
\constantwhen
Neither \tcode{To} nor \tcode{From}
Expand Down
Loading