Skip to content

Commit 9f97a8c

Browse files
authored
Merge 2024-06 CWG Motion 3
P2747R2 constexpr placement new
2 parents 52d5e3b + d7a5e0e commit 9f97a8c

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
@@ -3437,13 +3437,15 @@
34373437
\end{example}
34383438

34393439
\pnum
3440-
An operation that begins the lifetime of
3440+
Except during constant evaluation,
3441+
an operation that begins the lifetime of
34413442
an array of \tcode{unsigned char} or \tcode{std::byte}
34423443
implicitly creates objects within the region of storage occupied by the array.
34433444
\begin{note}
34443445
The array object provides storage for these objects.
34453446
\end{note}
3446-
Any implicit or explicit invocation of a function
3447+
Except during constant evaluation,
3448+
any implicit or explicit invocation of a function
34473449
named \tcode{\keyword{operator} \keyword{new}} or \tcode{\keyword{operator} \keyword{new}[]}
34483450
implicitly creates objects in the returned region of storage and
34493451
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
@@ -5471,12 +5471,7 @@
54715471

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

54815476
\pnum
54825477
The implementation may
@@ -7645,9 +7640,27 @@
76457640

76467641
\item
76477642
a \grammarterm{new-expression}\iref{expr.new},
7648-
unless the selected allocation function is
7643+
unless either
7644+
\begin{itemize}
7645+
\item
7646+
the selected allocation function is
76497647
a replaceable global allocation function\iref{new.delete.single,new.delete.array} and
7650-
the allocated storage is deallocated within the evaluation of $E$;
7648+
the allocated storage is deallocated within the evaluation of $E$, or
7649+
\item
7650+
the selected allocation function is
7651+
a non-allocating form\iref{new.delete.placement}
7652+
with an allocated type \tcode{T}, where
7653+
\begin{itemize}
7654+
\item
7655+
the placement argument to the \grammarterm{new-expression} points to
7656+
an object that is pointer-interconvertible with an object of type \tcode{T} or,
7657+
if T is an array type,
7658+
with the first element of an object of type \tcode{T}, and
7659+
\item
7660+
the placement argument points to storage
7661+
whose duration began within the evaluation of $E$;
7662+
\end{itemize}
7663+
\end{itemize}
76517664

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

77927797
\pnum
77937798
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}
@@ -2302,8 +2303,8 @@
23022303
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
23032304
void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
23042305

2305-
[[nodiscard]] void* operator new (std::size_t size, void* ptr) noexcept;
2306-
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
2306+
[[nodiscard]] constexpr void* operator new (std::size_t size, void* ptr) noexcept;
2307+
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
23072308
void operator delete (void* ptr, void*) noexcept;
23082309
void operator delete[](void* ptr, void*) noexcept;
23092310
\end{codeblock}
@@ -2836,7 +2837,7 @@
28362837

28372838
\indexlibrarymember{new}{operator}%
28382839
\begin{itemdecl}
2839-
[[nodiscard]] void* operator new(std::size_t size, void* ptr) noexcept;
2840+
[[nodiscard]] constexpr void* operator new(std::size_t size, void* ptr) noexcept;
28402841
\end{itemdecl}
28412842

28422843
\begin{itemdescr}
@@ -2861,7 +2862,7 @@
28612862

28622863
\indexlibrarymember{new}{operator}%
28632864
\begin{itemdecl}
2864-
[[nodiscard]] void* operator new[](std::size_t size, void* ptr) noexcept;
2865+
[[nodiscard]] constexpr void* operator new[](std::size_t size, void* ptr) noexcept;
28652866
\end{itemdecl}
28662867

28672868
\begin{itemdescr}

0 commit comments

Comments
 (0)