mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
change casing of 'Final_action' to 'final_action'
This commit is contained in:
@@ -3073,16 +3073,16 @@ Only if you need code that is not simply destructors of members executed, define
|
|||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct Final_action { // slightly simplified
|
struct final_action { // slightly simplified
|
||||||
A act;
|
A act;
|
||||||
Final_action(F a) :act{a} {}
|
final_action(F a) :act{a} {}
|
||||||
~Final_action() { act(); }
|
~final_action() { act(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
Final_action<A> finally(A act) // deduce action type
|
final_action<A> finally(A act) // deduce action type
|
||||||
{
|
{
|
||||||
return Final_action<A>{a};
|
return final_action<A>{a};
|
||||||
}
|
}
|
||||||
|
|
||||||
void test()
|
void test()
|
||||||
@@ -3093,12 +3093,12 @@ Only if you need code that is not simply destructors of members executed, define
|
|||||||
// ...
|
// ...
|
||||||
} // act done here
|
} // act done here
|
||||||
|
|
||||||
The whole purpose of `Final_action` is to get a piece of code (usually a lambda) executed upon destruction.
|
The whole purpose of `final_action` is to get a piece of code (usually a lambda) executed upon destruction.
|
||||||
|
|
||||||
**Note**: There are two general categories of classes that need a user-defined destructor:
|
**Note**: There are two general categories of classes that need a user-defined destructor:
|
||||||
|
|
||||||
* A class with a resource that is not already represented as a class with a destructor, e.g., a `vector` or a transaction class.
|
* A class with a resource that is not already represented as a class with a destructor, e.g., a `vector` or a transaction class.
|
||||||
* A class that exists primarily to execute an action upon destruction, such as a tracer or `Final_action`.
|
* A class that exists primarily to execute an action upon destruction, such as a tracer or `final_action`.
|
||||||
|
|
||||||
**Example, bad**:
|
**Example, bad**:
|
||||||
|
|
||||||
@@ -8167,7 +8167,7 @@ Error-handling rule summary:
|
|||||||
* [E.16: Destructors, deallocation, and `swap` must never fail](#Re-never-fail)
|
* [E.16: Destructors, deallocation, and `swap` must never fail](#Re-never-fail)
|
||||||
* [E.17: Don't try to catch every exception in every function](#Re-not-always)
|
* [E.17: Don't try to catch every exception in every function](#Re-not-always)
|
||||||
* [E.18: Minimize the use of explicit `try`/`catch`](#Re-catch)
|
* [E.18: Minimize the use of explicit `try`/`catch`](#Re-catch)
|
||||||
* [E.19: Use a `Final_action` object to express cleanup if no suitable resource handle is available](#Re-finally)
|
* [E.19: Use a `final_action` object to express cleanup if no suitable resource handle is available](#Re-finally)
|
||||||
|
|
||||||
* [E.25: ??? What to do in programs where exceptions cannot be thrown](#Re-no-throw)
|
* [E.25: ??? What to do in programs where exceptions cannot be thrown](#Re-no-throw)
|
||||||
* ???
|
* ???
|
||||||
@@ -8619,7 +8619,7 @@ Let cleanup actions on the unwinding path be handled by [RAII](#Re-raii).
|
|||||||
|
|
||||||
|
|
||||||
<a name="Re-finally"></a>
|
<a name="Re-finally"></a>
|
||||||
### E.19: Use a `Final_action` object to express cleanup if no suitable resource handle is available
|
### E.19: Use a `final_action` object to express cleanup if no suitable resource handle is available
|
||||||
|
|
||||||
**Reason**: `finally` is less verbose and harder to get wrong than `try`/`catch`.
|
**Reason**: `finally` is less verbose and harder to get wrong than `try`/`catch`.
|
||||||
|
|
||||||
@@ -11415,7 +11415,7 @@ The elements are mutable unless `T` is a `const` type. Basically an `array_view`
|
|||||||
<a name="SS-utilities"></a>
|
<a name="SS-utilities"></a>
|
||||||
## GSL.util: Utilities
|
## GSL.util: Utilities
|
||||||
|
|
||||||
* `finally` // `finally(f)` makes a `Final_act{f}` with a destructor that invokes `f`
|
* `finally` // `finally(f)` makes a `final_action{f}` with a destructor that invokes `f`
|
||||||
* `narrow_cast` // `narrow_cast<T>(x)` is `static_cast<T>(x)`
|
* `narrow_cast` // `narrow_cast<T>(x)` is `static_cast<T>(x)`
|
||||||
* `narrow` // `narrow<T>(x)` is `static_cast<T>(x)` if `static_cast<T>(x)==x` or it throws `narrowing_error`
|
* `narrow` // `narrow<T>(x)` is `static_cast<T>(x)` if `static_cast<T>(x)==x` or it throws `narrowing_error`
|
||||||
* `implicit` // "Marker" to put on single-argument constructors to explicitly make them non-explicit
|
* `implicit` // "Marker" to put on single-argument constructors to explicitly make them non-explicit
|
||||||
|
|||||||
Reference in New Issue
Block a user