tmp/tmp9v1v711q/{from.md → to.md}
RENAMED
|
@@ -1,27 +1,31 @@
|
|
| 1 |
-
####
|
| 2 |
|
| 3 |
-
These functions are reserved
|
| 4 |
-
displace the versions in the
|
| 5 |
-
provisions of
|
| 6 |
placement forms of `operator new` and `operator delete`.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
void* operator new(std::size_t size, void* ptr) noexcept;
|
| 10 |
```
|
| 11 |
|
| 12 |
*Returns:* `ptr`.
|
| 13 |
|
| 14 |
*Remarks:* Intentionally performs no other action.
|
| 15 |
|
|
|
|
|
|
|
| 16 |
This can be useful for constructing an object at a known address:
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
void* place = operator new(sizeof(Something));
|
| 20 |
Something* p = new (place) Something();
|
| 21 |
```
|
| 22 |
|
|
|
|
|
|
|
| 23 |
``` cpp
|
| 24 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 25 |
```
|
| 26 |
|
| 27 |
*Returns:* `ptr`.
|
|
@@ -37,11 +41,11 @@ void operator delete(void* ptr, void*) noexcept;
|
|
| 37 |
*Requires:* If an implementation has strict pointer
|
| 38 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 39 |
safely-derived pointer.
|
| 40 |
|
| 41 |
*Remarks:* Default function called when any part of the initialization
|
| 42 |
-
in a placement new
|
| 43 |
placement operator new terminates by throwing an
|
| 44 |
exception ([[expr.new]]).
|
| 45 |
|
| 46 |
``` cpp
|
| 47 |
void operator delete[](void* ptr, void*) noexcept;
|
|
@@ -52,8 +56,9 @@ void operator delete[](void* ptr, void*) noexcept;
|
|
| 52 |
*Requires:* If an implementation has strict pointer
|
| 53 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 54 |
safely-derived pointer.
|
| 55 |
|
| 56 |
*Remarks:* Default function called when any part of the initialization
|
| 57 |
-
in a placement new
|
| 58 |
-
operator new terminates by throwing an
|
|
|
|
| 59 |
|
|
|
|
| 1 |
+
#### Non-allocating forms <a id="new.delete.placement">[[new.delete.placement]]</a>
|
| 2 |
|
| 3 |
+
These functions are reserved; a C++program may not define functions that
|
| 4 |
+
displace the versions in the C++standard library ([[constraints]]). The
|
| 5 |
+
provisions of [[basic.stc.dynamic]] do not apply to these reserved
|
| 6 |
placement forms of `operator new` and `operator delete`.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
void* operator new(std::size_t size, void* ptr) noexcept;
|
| 10 |
```
|
| 11 |
|
| 12 |
*Returns:* `ptr`.
|
| 13 |
|
| 14 |
*Remarks:* Intentionally performs no other action.
|
| 15 |
|
| 16 |
+
[*Example 1*:
|
| 17 |
+
|
| 18 |
This can be useful for constructing an object at a known address:
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
void* place = operator new(sizeof(Something));
|
| 22 |
Something* p = new (place) Something();
|
| 23 |
```
|
| 24 |
|
| 25 |
+
— *end example*]
|
| 26 |
+
|
| 27 |
``` cpp
|
| 28 |
void* operator new[](std::size_t size, void* ptr) noexcept;
|
| 29 |
```
|
| 30 |
|
| 31 |
*Returns:* `ptr`.
|
|
|
|
| 41 |
*Requires:* If an implementation has strict pointer
|
| 42 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 43 |
safely-derived pointer.
|
| 44 |
|
| 45 |
*Remarks:* Default function called when any part of the initialization
|
| 46 |
+
in a placement *new-expression* that invokes the library’s non-array
|
| 47 |
placement operator new terminates by throwing an
|
| 48 |
exception ([[expr.new]]).
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
void operator delete[](void* ptr, void*) noexcept;
|
|
|
|
| 56 |
*Requires:* If an implementation has strict pointer
|
| 57 |
safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
|
| 58 |
safely-derived pointer.
|
| 59 |
|
| 60 |
*Remarks:* Default function called when any part of the initialization
|
| 61 |
+
in a placement *new-expression* that invokes the library’s array
|
| 62 |
+
placement operator new terminates by throwing an
|
| 63 |
+
exception ([[expr.new]]).
|
| 64 |
|