mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
exceptionsand const
Added to E.15
This commit is contained in:
parent
81493f331c
commit
fa1d0e5995
|
@ -14139,10 +14139,16 @@ To prevent slicing.
|
|||
// ...
|
||||
}
|
||||
|
||||
Instead, use:
|
||||
Instead, use a reference:
|
||||
|
||||
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
|
||||
|
||||
Flag by-value exceptions if their types are part of a hierarchy (could require whole-program analysis to be perfect).
|
||||
|
|
Loading…
Reference in New Issue
Block a user