Skip to content

P2747R2 constexpr placement new #7097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2024
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
6 changes: 4 additions & 2 deletions source/basic.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3437,13 +3437,15 @@
\end{example}

\pnum
An operation that begins the lifetime of
Except during constant evaluation,
an operation that begins the lifetime of
an array of \tcode{unsigned char} or \tcode{std::byte}
implicitly creates objects within the region of storage occupied by the array.
\begin{note}
The array object provides storage for these objects.
\end{note}
Any implicit or explicit invocation of a function
Except during constant evaluation,
any implicit or explicit invocation of a function
named \tcode{\keyword{operator} \keyword{new}} or \tcode{\keyword{operator} \keyword{new}[]}
implicitly creates objects in the returned region of storage and
returns a pointer to a suitable created object.
Expand Down
37 changes: 21 additions & 16 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5471,12 +5471,7 @@

\pnum
During an evaluation of a constant expression,
a call to an allocation function is always omitted.
\begin{note}
Only \grammarterm{new-expression}{s} that would otherwise result in
a call to a replaceable global allocation function
can be evaluated in constant expressions\iref{expr.const}.
\end{note}
a call to a replaceable allocation function is always omitted\iref{expr.const}.

\pnum
The implementation may
Expand Down Expand Up @@ -7645,9 +7640,27 @@

\item
a \grammarterm{new-expression}\iref{expr.new},
unless the selected allocation function is
unless either
\begin{itemize}
\item
the selected allocation function is
a replaceable global allocation function\iref{new.delete.single,new.delete.array} and
the allocated storage is deallocated within the evaluation of $E$;
the allocated storage is deallocated within the evaluation of $E$, or
\item
the selected allocation function is
a non-allocating form\iref{new.delete.placement}
with an allocated type \tcode{T}, where
\begin{itemize}
\item
the placement argument to the \grammarterm{new-expression} points to
an object that is pointer-interconvertible with an object of type \tcode{T} or,
if T is an array type,
with the first element of an object of type \tcode{T}, and
\item
the placement argument points to storage
whose duration began within the evaluation of $E$;
\end{itemize}
\end{itemize}

\item
a \grammarterm{delete-expression}\iref{expr.delete},
Expand Down Expand Up @@ -7780,14 +7793,6 @@
the evaluation of the body of a member function of \tcode{std::allocator<T>}
as defined in \ref{allocator.members}, where \tcode{T} is a literal type,
is ignored.
Similarly, the evaluation of the body of
\tcode{std::construct_at} or
\tcode{std::ranges::construct_at}
is considered to include only
the initialization of the \tcode{T} object
if the first argument (of type \tcode{T*}) points
to storage allocated with \tcode{std::allocator<T>} or
to an object whose lifetime began within the evaluation of $E$.

\pnum
For the purposes of determining whether $E$ is a core constant expression,
Expand Down
2 changes: 1 addition & 1 deletion source/preprocessor.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@
\defnxname{cpp_char8_t} & \tcode{202207L} \\ \rowsep
\defnxname{cpp_concepts} & \tcode{202002L} \\ \rowsep
\defnxname{cpp_conditional_explicit} & \tcode{201806L} \\ \rowsep
\defnxname{cpp_constexpr} & \tcode{202306L} \\ \rowsep
\defnxname{cpp_constexpr} & \tcode{202406L} \\ \rowsep
\defnxname{cpp_constexpr_dynamic_alloc} & \tcode{201907L} \\ \rowsep
\defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep
\defnxname{cpp_consteval} & \tcode{202211L} \\ \rowsep
Expand Down
9 changes: 5 additions & 4 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
#define @\defnlibxname{cpp_lib_constexpr_functional}@ 201907L // freestanding, also in \libheader{functional}
#define @\defnlibxname{cpp_lib_constexpr_iterator}@ 201811L // freestanding, also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_constexpr_memory}@ 202202L // freestanding, also in \libheader{memory}
#define @\defnlibxname{cpp_lib_constexpr_new}@ 202406L // freestanding, also in \libheader{new}
#define @\defnlibxname{cpp_lib_constexpr_numeric}@ 201911L // also in \libheader{numeric}
#define @\defnlibxname{cpp_lib_constexpr_string}@ 201907L // also in \libheader{string}
#define @\defnlibxname{cpp_lib_constexpr_string_view}@ 201811L // also in \libheader{string_view}
Expand Down Expand Up @@ -2302,8 +2303,8 @@
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;

[[nodiscard]] void* operator new (std::size_t size, void* ptr) noexcept;
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
[[nodiscard]] constexpr void* operator new (std::size_t size, void* ptr) noexcept;
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
void operator delete (void* ptr, void*) noexcept;
void operator delete[](void* ptr, void*) noexcept;
\end{codeblock}
Expand Down Expand Up @@ -2836,7 +2837,7 @@

\indexlibrarymember{new}{operator}%
\begin{itemdecl}
[[nodiscard]] void* operator new(std::size_t size, void* ptr) noexcept;
[[nodiscard]] constexpr void* operator new(std::size_t size, void* ptr) noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -2861,7 +2862,7 @@

\indexlibrarymember{new}{operator}%
\begin{itemdecl}
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
\end{itemdecl}

\begin{itemdescr}
Expand Down
Loading