Skip to content

Commit 617eeef

Browse files
committed
P2747R2 constexpr placement new
1 parent 6d67d20 commit 617eeef

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

source/basic.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,13 +3432,15 @@
34323432
\end{example}
34333433

34343434
\pnum
3435-
An operation that begins the lifetime of
3435+
Except during constant evaluation,
3436+
an operation that begins the lifetime of
34363437
an array of \tcode{unsigned char} or \tcode{std::byte}
34373438
implicitly creates objects within the region of storage occupied by the array.
34383439
\begin{note}
34393440
The array object provides storage for these objects.
34403441
\end{note}
3441-
Any implicit or explicit invocation of a function
3442+
Except during constant evaluation,
3443+
any implicit or explicit invocation of a function
34423444
named \tcode{\keyword{operator} \keyword{new}} or \tcode{\keyword{operator} \keyword{new}[]}
34433445
implicitly creates objects in the returned region of storage and
34443446
returns a pointer to a suitable created object.

source/expressions.tex

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5441,12 +5441,7 @@
54415441

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

54515446
\pnum
54525447
The implementation may
@@ -7619,9 +7614,27 @@
76197614

76207615
\item
76217616
a \grammarterm{new-expression}\iref{expr.new},
7622-
unless the selected allocation function is
7617+
unless either
7618+
\begin{itemize}
7619+
\item
7620+
the selected allocation function is
76237621
a replaceable global allocation function\iref{new.delete.single,new.delete.array} and
7624-
the allocated storage is deallocated within the evaluation of $E$;
7622+
the allocated storage is deallocated within the evaluation of $E$, or
7623+
\item
7624+
the selected allocation function is
7625+
a non-allocating form\iref{new.delete.placement}
7626+
with an allocated type \tcode{T}, where
7627+
\begin{itemize}
7628+
\item
7629+
the placement argument to the \grammarterm{new-expression} points to
7630+
an object that is pointer-interconvertible with an object of type \tcode{T} or,
7631+
if T is an array type,
7632+
with the first element of an object of type \tcode{T}, and
7633+
\item
7634+
the placement argument points to storage
7635+
whose duration began within the evaluation of \tcode{E};
7636+
\end{itemize}
7637+
\end{itemize}
76257638

76267639
\item
76277640
a \grammarterm{delete-expression}\iref{expr.delete},
@@ -7754,14 +7767,6 @@
77547767
the evaluation of the body of a member function of \tcode{std::allocator<T>}
77557768
as defined in \ref{allocator.members}, where \tcode{T} is a literal type,
77567769
is ignored.
7757-
Similarly, the evaluation of the body of
7758-
\tcode{std::construct_at} or
7759-
\tcode{std::ranges::construct_at}
7760-
is considered to include only
7761-
the initialization of the \tcode{T} object
7762-
if the first argument (of type \tcode{T*}) points
7763-
to storage allocated with \tcode{std::allocator<T>} or
7764-
to an object whose lifetime began within the evaluation of $E$.
77657770

77667771
\pnum
77677772
For the purposes of determining whether $E$ is a core constant expression,

source/preprocessor.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@
18481848
\defnxname{cpp_char8_t} & \tcode{202207L} \\ \rowsep
18491849
\defnxname{cpp_concepts} & \tcode{202002L} \\ \rowsep
18501850
\defnxname{cpp_conditional_explicit} & \tcode{201806L} \\ \rowsep
1851-
\defnxname{cpp_constexpr} & \tcode{202306L} \\ \rowsep
1851+
\defnxname{cpp_constexpr} & \tcode{202406L} \\ \rowsep
18521852
\defnxname{cpp_constexpr_dynamic_alloc} & \tcode{201907L} \\ \rowsep
18531853
\defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep
18541854
\defnxname{cpp_consteval} & \tcode{202211L} \\ \rowsep

source/support.tex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@
610610
#define @\defnlibxname{cpp_lib_constexpr_functional}@ 201907L // freestanding, also in \libheader{functional}
611611
#define @\defnlibxname{cpp_lib_constexpr_iterator}@ 201811L // freestanding, also in \libheader{iterator}
612612
#define @\defnlibxname{cpp_lib_constexpr_memory}@ 202202L // freestanding, also in \libheader{memory}
613+
#define @\defnlibxname{cpp_lib_constexpr_new}@ 202406L // freestanding, also in \libheader{new}
613614
#define @\defnlibxname{cpp_lib_constexpr_numeric}@ 201911L // also in \libheader{numeric}
614615
#define @\defnlibxname{cpp_lib_constexpr_string}@ 201907L // also in \libheader{string}
615616
#define @\defnlibxname{cpp_lib_constexpr_string_view}@ 201811L // also in \libheader{string_view}
@@ -2299,8 +2300,8 @@
22992300
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
23002301
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
23012302

2302-
[[nodiscard]] void* operator new (std::size_t size, void* ptr) noexcept;
2303-
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
2303+
[[nodiscard]] constexpr void* operator new (std::size_t size, void* ptr) noexcept;
2304+
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
23042305
void operator delete (void* ptr, void*) noexcept;
23052306
void operator delete[](void* ptr, void*) noexcept;
23062307
\end{codeblock}
@@ -2833,7 +2834,7 @@
28332834

28342835
\indexlibrarymember{new}{operator}%
28352836
\begin{itemdecl}
2836-
[[nodiscard]] void* operator new(std::size_t size, void* ptr) noexcept;
2837+
[[nodiscard]] constexpr void* operator new(std::size_t size, void* ptr) noexcept;
28372838
\end{itemdecl}
28382839

28392840
\begin{itemdescr}
@@ -2858,7 +2859,7 @@
28582859

28592860
\indexlibrarymember{new}{operator}%
28602861
\begin{itemdecl}
2861-
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
2862+
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
28622863
\end{itemdecl}
28632864

28642865
\begin{itemdescr}

0 commit comments

Comments
 (0)