diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 77e21c7..b0b0c9c 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -2849,12 +2849,24 @@ Suppression of unused parameter warnings. ##### Example - X* find(map& m, const string& s, Hint); // once upon a time, a hint was used + widget* find(const set& s, const widget& w, Hint); // once upon a time, a hint was used ##### Note Allowing parameters to be unnamed was introduced in the early 1980 to address this problem. +If parameters are conditionally unused, declare them with the `[[maybe_unused]]` attribute. +For example: + + template + Value* find(const set& s, const Value& v, [[maybe_unused]] Hint h) + { + if constexpr (sizeof(Value) > CacheSize) + { + // a hint is used only if Value is of a certain size + } + } + ##### Enforcement Flag named unused parameters.