Editorial: Moved ES.60 into proper order

This commit is contained in:
hsutter 2016-02-22 09:29:32 -08:00
parent 1b3efdf1e8
commit a4cfded181

View File

@ -9564,33 +9564,6 @@ Constructs that cannot overflow do not overflow (and usually run faster):
Look for explicit range checks and heuristically suggest alternatives.
### <a name="Res-new"></a>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.
### <a name="Res-move"></a>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.
### <a name="Res-new"></a>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.
### <a name="Res-del"></a>ES.61: delete arrays using `delete[]` and non-arrays using `delete`
##### Reason