tmp/tmp81hp70c_/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### General <a id="basic.stc.dynamic.general">[[basic.stc.dynamic.general]]</a>
|
| 2 |
+
|
| 3 |
+
Objects can be created dynamically during program execution
|
| 4 |
+
[[intro.execution]], using *new-expression*s [[expr.new]], and destroyed
|
| 5 |
+
using *delete-expression*s [[expr.delete]]. A C++ implementation
|
| 6 |
+
provides access to, and management of, dynamic storage via the global
|
| 7 |
+
*allocation functions* `operator new` and `operator new[]` and the
|
| 8 |
+
global *deallocation functions* `operator delete` and
|
| 9 |
+
`operator delete[]`.
|
| 10 |
+
|
| 11 |
+
[*Note 1*: The non-allocating forms described in
|
| 12 |
+
[[new.delete.placement]] do not perform allocation or
|
| 13 |
+
deallocation. — *end note*]
|
| 14 |
+
|
| 15 |
+
The library provides default definitions for the global allocation and
|
| 16 |
+
deallocation functions. Some global allocation and deallocation
|
| 17 |
+
functions are replaceable [[new.delete]]; these are attached to the
|
| 18 |
+
global module [[module.unit]]. A C++ program shall provide at most one
|
| 19 |
+
definition of a replaceable allocation or deallocation function. Any
|
| 20 |
+
such function definition replaces the default version provided in the
|
| 21 |
+
library [[replacement.functions]]. The following allocation and
|
| 22 |
+
deallocation functions [[support.dynamic]] are implicitly declared in
|
| 23 |
+
global scope in each translation unit of a program.
|
| 24 |
+
|
| 25 |
+
``` cpp
|
| 26 |
+
[[nodiscard]] void* operator new(std::size_t);
|
| 27 |
+
[[nodiscard]] void* operator new(std::size_t, std::align_val_t);
|
| 28 |
+
|
| 29 |
+
void operator delete(void*) noexcept;
|
| 30 |
+
void operator delete(void*, std::size_t) noexcept;
|
| 31 |
+
void operator delete(void*, std::align_val_t) noexcept;
|
| 32 |
+
void operator delete(void*, std::size_t, std::align_val_t) noexcept;
|
| 33 |
+
|
| 34 |
+
[[nodiscard]] void* operator new[](std::size_t);
|
| 35 |
+
[[nodiscard]] void* operator new[](std::size_t, std::align_val_t);
|
| 36 |
+
|
| 37 |
+
void operator delete[](void*) noexcept;
|
| 38 |
+
void operator delete[](void*, std::size_t) noexcept;
|
| 39 |
+
void operator delete[](void*, std::align_val_t) noexcept;
|
| 40 |
+
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
These implicit declarations introduce only the function names
|
| 44 |
+
`operator new`, `operator new[]`, `operator delete`, and
|
| 45 |
+
`operator delete[]`.
|
| 46 |
+
|
| 47 |
+
[*Note 2*: The implicit declarations do not introduce the names `std`,
|
| 48 |
+
`std::size_t`, `std::align_val_t`, or any other names that the library
|
| 49 |
+
uses to declare these names. Thus, a *new-expression*,
|
| 50 |
+
*delete-expression*, or function call that refers to one of these
|
| 51 |
+
functions without importing or including the header `<new>` or importing
|
| 52 |
+
a C++ library module [[std.modules]] is well-formed. However, referring
|
| 53 |
+
to `std` or `std::size_t` or `std::align_val_t` is ill-formed unless a
|
| 54 |
+
standard library declaration
|
| 55 |
+
[[cstddef.syn]], [[new.syn]], [[std.modules]] of that name precedes
|
| 56 |
+
[[basic.lookup.general]] the use of that name. — *end note*]
|
| 57 |
+
|
| 58 |
+
Allocation and/or deallocation functions may also be declared and
|
| 59 |
+
defined for any class [[class.free]].
|
| 60 |
+
|
| 61 |
+
If the behavior of an allocation or deallocation function does not
|
| 62 |
+
satisfy the semantic constraints specified in
|
| 63 |
+
[[basic.stc.dynamic.allocation]] and
|
| 64 |
+
[[basic.stc.dynamic.deallocation]], the behavior is undefined.
|
| 65 |
+
|