From Jason Turner

[new.delete.array]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppcppl4y7/{from.md → to.md} +39 -43
tmp/tmppcppl4y7/{from.md → to.md} RENAMED
@@ -1,19 +1,16 @@
1
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
2
 
3
  ``` cpp
4
- void* operator new[](std::size_t size);
5
- void* operator new[](std::size_t size, std::align_val_t alignment);
6
  ```
7
 
8
- *Effects:* The allocation functions ([[basic.stc.dynamic.allocation]])
9
- called by the array form of a *new-expression* ([[expr.new]]) to
10
- allocate `size` bytes of storage. The second form is called for a type
11
- with new-extended alignment, and allocates storage with the specified
12
- alignment. The first form is called otherwise, and allocates storage
13
- suitably aligned to represent any array object of that size or smaller,
14
- provided the object’s type does not have new-extended alignment. [^33]
15
 
16
  *Replaceable:* A C++ program may define functions with either of these
17
  function signatures, and thereby displace the default versions defined
18
  by the C++ standard library.
19
 
@@ -23,12 +20,13 @@ functions.
23
 
24
  *Default behavior:* Returns `operator new(size)`, or
25
  `operator new(size, alignment)`, respectively.
26
 
27
  ``` cpp
28
- void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
29
- void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept;
 
30
  ```
31
 
32
  *Effects:* Same as above, except that these are called by a placement
33
  version of a *new-expression* when a C++ program prefers a null pointer
34
  result as an error indication, instead of a `bad_alloc` exception.
@@ -36,11 +34,11 @@ result as an error indication, instead of a `bad_alloc` exception.
36
  *Replaceable:* A C++ program may define functions with either of these
37
  function signatures, and thereby displace the default versions defined
38
  by the C++ standard library.
39
 
40
  *Required behavior:* Return a non-null pointer to suitably aligned
41
- storage ([[basic.stc.dynamic]]), or else return a null pointer. Each of
42
  these nothrow versions of `operator new[]` returns a pointer obtained as
43
  if acquired from the (possibly replaced) corresponding non-placement
44
  function. This requirement is binding on any replacement versions of
45
  these functions.
46
 
@@ -54,13 +52,13 @@ void operator delete[](void* ptr) noexcept;
54
  void operator delete[](void* ptr, std::size_t size) noexcept;
55
  void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
56
  void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
57
  ```
58
 
59
- *Effects:* The deallocation
60
- functions ([[basic.stc.dynamic.deallocation]]) called by the array form
61
- of a *delete-expression* to render the value of `ptr` invalid.
62
 
63
  *Replaceable:* A C++ program may define functions with any of these
64
  function signatures, and thereby displace the default versions defined
65
  by the C++ standard library.
66
 
@@ -71,26 +69,26 @@ define the corresponding version without the `size` parameter.
71
 
72
  [*Note 1*: The default behavior below may change in the future, which
73
  will require replacing both deallocation functions when replacing the
74
  allocation function. — *end note*]
75
 
76
- *Requires:* `ptr` shall be a null pointer or its value shall represent
77
- the address of a block of memory allocated by an earlier call to a
78
- (possibly replaced) `operator new[](std::size_t)` or
79
  `operator new[](std::size_t, std::align_val_t)` which has not been
80
  invalidated by an intervening call to `operator delete[]`.
81
 
82
- *Requires:* If an implementation has strict pointer
83
- safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
84
- safely-derived pointer.
85
 
86
- *Requires:* If the `alignment` parameter is not present, `ptr` shall
87
- have been returned by an allocation function without an `alignment`
88
- parameter. If present, the `alignment` argument shall equal the
89
- `alignment` argument passed to the allocation function that returned
90
- `ptr`. If present, the `size` argument shall equal the `size` argument
91
- passed to the allocation function that returned `ptr`.
92
 
93
  *Required behavior:* A call to an `operator delete[]` with a `size`
94
  parameter may be changed to a call to the corresponding
95
  `operator delete[]` without a `size` parameter, without affecting memory
96
  allocation.
@@ -108,34 +106,32 @@ function.
108
  ``` cpp
109
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
110
  void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
111
  ```
112
 
113
- *Effects:* The deallocation
114
- functions ([[basic.stc.dynamic.deallocation]]) called by the
115
- implementation to render the value of `ptr` invalid when the constructor
116
- invoked from a nothrow placement version of the array *new-expression*
117
- throws an exception.
118
 
119
  *Replaceable:* A C++ program may define functions with either of these
120
  function signatures, and thereby displace the default versions defined
121
  by the C++ standard library.
122
 
123
- *Requires:* `ptr` shall be a null pointer or its value shall represent
124
- the address of a block of memory allocated by an earlier call to a
125
- (possibly replaced) `operator new[](std::size_t)` or
126
  `operator new[](std::size_t, std::align_val_t)` which has not been
127
  invalidated by an intervening call to `operator delete[]`.
128
 
129
- *Requires:* If an implementation has strict pointer
130
- safety ([[basic.stc.dynamic.safety]]) then `ptr` shall be a
131
- safely-derived pointer.
132
 
133
- *Requires:* If the `alignment` parameter is not present, `ptr` shall
134
- have been returned by an allocation function without an `alignment`
135
- parameter. If present, the `alignment` argument shall equal the
136
- `alignment` argument passed to the allocation function that returned
137
- `ptr`.
138
 
139
  *Default behavior:* Calls `operator delete[](ptr)`, or
140
  `operator delete[](ptr, alignment)`, respectively.
141
 
 
1
  #### Array forms <a id="new.delete.array">[[new.delete.array]]</a>
2
 
3
  ``` cpp
4
+ [[nodiscard]] void* operator new[](std::size_t size);
5
+ [[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment);
6
  ```
7
 
8
+ *Effects:* The allocation functions [[basic.stc.dynamic.allocation]]
9
+ called by the array form of a *new-expression*[[expr.new]] to allocate
10
+ `size` bytes of storage. The second form is called for a type with
11
+ new-extended alignment, and the first form is called otherwise. [^33]
 
 
 
12
 
13
  *Replaceable:* A C++ program may define functions with either of these
14
  function signatures, and thereby displace the default versions defined
15
  by the C++ standard library.
16
 
 
20
 
21
  *Default behavior:* Returns `operator new(size)`, or
22
  `operator new(size, alignment)`, respectively.
23
 
24
  ``` cpp
25
+ [[nodiscard]] void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
26
+ [[nodiscard]] void* operator new[](std::size_t size, std::align_val_t alignment,
27
+ const std::nothrow_t&) noexcept;
28
  ```
29
 
30
  *Effects:* Same as above, except that these are called by a placement
31
  version of a *new-expression* when a C++ program prefers a null pointer
32
  result as an error indication, instead of a `bad_alloc` exception.
 
34
  *Replaceable:* A C++ program may define functions with either of these
35
  function signatures, and thereby displace the default versions defined
36
  by the C++ standard library.
37
 
38
  *Required behavior:* Return a non-null pointer to suitably aligned
39
+ storage [[basic.stc.dynamic]], or else return a null pointer. Each of
40
  these nothrow versions of `operator new[]` returns a pointer obtained as
41
  if acquired from the (possibly replaced) corresponding non-placement
42
  function. This requirement is binding on any replacement versions of
43
  these functions.
44
 
 
52
  void operator delete[](void* ptr, std::size_t size) noexcept;
53
  void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
54
  void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
55
  ```
56
 
57
+ *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
58
+ called by the array form of a *delete-expression* to render the value of
59
+ `ptr` invalid.
60
 
61
  *Replaceable:* A C++ program may define functions with any of these
62
  function signatures, and thereby displace the default versions defined
63
  by the C++ standard library.
64
 
 
69
 
70
  [*Note 1*: The default behavior below may change in the future, which
71
  will require replacing both deallocation functions when replacing the
72
  allocation function. — *end note*]
73
 
74
+ *Preconditions:* `ptr` is a null pointer or its value represents the
75
+ address of a block of memory allocated by an earlier call to a (possibly
76
+ replaced) `operator new[](std::size_t)` or
77
  `operator new[](std::size_t, std::align_val_t)` which has not been
78
  invalidated by an intervening call to `operator delete[]`.
79
 
80
+ *Preconditions:* If an implementation has strict pointer
81
+ safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
82
+ pointer.
83
 
84
+ *Preconditions:* If the `alignment` parameter is not present, `ptr` was
85
+ returned by an allocation function without an `alignment` parameter. If
86
+ present, the `alignment` argument is equal to the `alignment` argument
87
+ passed to the allocation function that returned `ptr`. If present, the
88
+ `size` argument is equal to the `size` argument passed to the allocation
89
+ function that returned `ptr`.
90
 
91
  *Required behavior:* A call to an `operator delete[]` with a `size`
92
  parameter may be changed to a call to the corresponding
93
  `operator delete[]` without a `size` parameter, without affecting memory
94
  allocation.
 
106
  ``` cpp
107
  void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
108
  void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept;
109
  ```
110
 
111
+ *Effects:* The deallocation functions [[basic.stc.dynamic.deallocation]]
112
+ called by the implementation to render the value of `ptr` invalid when
113
+ the constructor invoked from a nothrow placement version of the array
114
+ *new-expression* throws an exception.
 
115
 
116
  *Replaceable:* A C++ program may define functions with either of these
117
  function signatures, and thereby displace the default versions defined
118
  by the C++ standard library.
119
 
120
+ *Preconditions:* `ptr` is a null pointer or its value represents the
121
+ address of a block of memory allocated by an earlier call to a (possibly
122
+ replaced) `operator new[](std::size_t)` or
123
  `operator new[](std::size_t, std::align_val_t)` which has not been
124
  invalidated by an intervening call to `operator delete[]`.
125
 
126
+ *Preconditions:* If an implementation has strict pointer
127
+ safety [[basic.stc.dynamic.safety]] then `ptr` is a safely-derived
128
+ pointer.
129
 
130
+ *Preconditions:* If the `alignment` parameter is not present, `ptr` was
131
+ returned by an allocation function without an `alignment` parameter. If
132
+ present, the `alignment` argument is equal to the `alignment` argument
133
+ passed to the allocation function that returned `ptr`.
 
134
 
135
  *Default behavior:* Calls `operator delete[](ptr)`, or
136
  `operator delete[](ptr, alignment)`, respectively.
137