diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 6be6c3e..718d108 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -9564,33 +9564,6 @@ Constructs that cannot overflow do not overflow (and usually run faster): Look for explicit range checks and heuristically suggest alternatives. -### ES.60: Avoid `new` and `delete` outside resource management functions - -##### Reason - -Direct resource management in application code is error-prone and tedious. - -##### Note - -also known as "No naked `new`!" - -##### Example, bad - - void f(int n) - { - auto p = new X[n]; // n default constructed Xs - // ... - delete[] p; - } - -There can be code in the `...` part that causes the `delete` never to happen. - -**See also**: [R: Resource management](#S-resource). - -##### Enforcement - -Flag naked `new`s and naked `delete`s. - ### ES.56: Write `std::move()` only when you need to explicitly move an object to another scope @@ -9700,6 +9673,34 @@ The language already knows that a returned value is a temporary object that can * Flag when an object is potentially moved from and the next operation is a `const` operation; there should first be an intervening non-`const` operation, ideally assignment, to first reset the object's value. +### ES.60: Avoid `new` and `delete` outside resource management functions + +##### Reason + +Direct resource management in application code is error-prone and tedious. + +##### Note + +also known as "No naked `new`!" + +##### Example, bad + + void f(int n) + { + auto p = new X[n]; // n default constructed Xs + // ... + delete[] p; + } + +There can be code in the `...` part that causes the `delete` never to happen. + +**See also**: [R: Resource management](#S-resource). + +##### Enforcement + +Flag naked `new`s and naked `delete`s. + + ### ES.61: delete arrays using `delete[]` and non-arrays using `delete` ##### Reason