mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
exceptionsand const
Added to E.15
This commit is contained in:
@@ -14139,10 +14139,16 @@ To prevent slicing.
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
Instead, use:
|
Instead, use a reference:
|
||||||
|
|
||||||
catch (exception& e) { /* ... */ }
|
catch (exception& e) { /* ... */ }
|
||||||
|
|
||||||
|
of - typically better stil - a `const` reference:
|
||||||
|
|
||||||
|
catch (const exception& e) { /* ... */ }
|
||||||
|
|
||||||
|
Most handlers do not modify their exception and in general we [recommend use of `const`](#Res-const).
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
Flag by-value exceptions if their types are part of a hierarchy (could require whole-program analysis to be perfect).
|
Flag by-value exceptions if their types are part of a hierarchy (could require whole-program analysis to be perfect).
|
||||||
|
|||||||
Reference in New Issue
Block a user