diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 3493973..a156fcd 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -3073,16 +3073,16 @@ Only if you need code that is not simply destructors of members executed, define **Example**: template - struct Final_action { // slightly simplified + struct final_action { // slightly simplified A act; - Final_action(F a) :act{a} {} - ~Final_action() { act(); } + final_action(F a) :act{a} {} + ~final_action() { act(); } }; template - Final_action finally(A act) // deduce action type + final_action finally(A act) // deduce action type { - return Final_action{a}; + return final_action{a}; } void test() @@ -3093,12 +3093,12 @@ Only if you need code that is not simply destructors of members executed, define // ... } // 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: * 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**: @@ -8167,7 +8167,7 @@ Error-handling rule summary: * [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.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) * ??? @@ -8619,7 +8619,7 @@ Let cleanup actions on the unwinding path be handled by [RAII](#Re-raii). -### 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`. @@ -11415,7 +11415,7 @@ The elements are mutable unless `T` is a `const` type. Basically an `array_view` ## 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(x)` is `static_cast(x)` * `narrow` // `narrow(x)` is `static_cast(x)` if `static_cast(x)==x` or it throws `narrowing_error` * `implicit` // "Marker" to put on single-argument constructors to explicitly make them non-explicit