tmp/tmpli0mpseo/{from.md → to.md}
RENAMED
|
@@ -1,41 +1,11 @@
|
|
| 1 |
-
###
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
**Rationale:**
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
write `"custom deallocation"` twice, once for the single-object delete
|
| 12 |
-
and once for the array delete.
|
| 13 |
-
|
| 14 |
-
``` cpp
|
| 15 |
-
#include <cstdio>
|
| 16 |
-
#include <cstdlib>
|
| 17 |
-
#include <new>
|
| 18 |
-
|
| 19 |
-
void* operator new(std::size_t size) throw(std::bad_alloc) {
|
| 20 |
-
return std::malloc(size);
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
void operator delete(void* ptr) throw() {
|
| 24 |
-
std::puts("custom deallocation");
|
| 25 |
-
std::free(ptr);
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
int main() {
|
| 29 |
-
int* i = new int;
|
| 30 |
-
delete i; // single-object delete
|
| 31 |
-
int* a = new int[3];
|
| 32 |
-
delete [] a; // array delete
|
| 33 |
-
}
|
| 34 |
-
```
|
| 35 |
-
|
| 36 |
-
[[new.delete.single]] **Change:** `operator new` may throw exceptions
|
| 37 |
-
other than `std::bad_alloc`. **Rationale:** Consistent application of
|
| 38 |
-
`noexcept`. **Effect on original feature:** Valid C++03code that assumes
|
| 39 |
-
that global `operator new` only throws `std::bad_alloc` may execute
|
| 40 |
-
differently in this International Standard.
|
| 41 |
|
|
|
|
| 1 |
+
### [[support]]: language support library <a id="diff.cpp03.language.support">[[diff.cpp03.language.support]]</a>
|
| 2 |
+
|
| 3 |
+
**Change:** `operator new` may throw exceptions other than
|
| 4 |
+
`std::bad_alloc`. **Rationale:** Consistent application of `noexcept`.
|
| 5 |
+
**Effect on original feature:** Valid C++03 code that assumes that
|
| 6 |
+
global `operator new` only throws `std::bad_alloc` may execute
|
| 7 |
+
differently in this International Standard. Valid C++03 code that
|
| 8 |
+
replaces the global replaceable `operator new` is ill-formed in this
|
| 9 |
+
International Standard, because the exception specification of
|
| 10 |
+
`throw(std::bad_alloc)` was removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|