diff --git a/rules/S6006/cfamily/rule.adoc b/rules/S6006/cfamily/rule.adoc index 5849289881..401914100f 100644 --- a/rules/S6006/cfamily/rule.adoc +++ b/rules/S6006/cfamily/rule.adoc @@ -1,9 +1,8 @@ == Why is this an issue? -``{cpp}17`` introduced ``++as_const++``: a helper function that converts a value to its corresponding const value in a succinct and more explicit way. +{cpp}17 introduced ``++as_const++``: a helper function that converts a value to its corresponding const value succinctly and more explicitly. - -This is usually done to force an overloaded function call on a non-const object to resolve to the const alternative. This also can be used to instantiate a template with a const type rather than the original non-const one. +This is usually done to force an overloaded function call on a non-const object to resolve to the const alternative. Or to instantiate a template with a const type rather than the original non-const one. This rule detects casts that can be replaced by ``++as_const++``. @@ -11,7 +10,7 @@ This rule detects casts that can be replaced by ``++as_const++``. === Noncompliant code example -[source,cpp] +[source,cpp,diff-id=1,diff-type=noncompliant] ---- void fn(std::vector& vec); void fn(const std::vector& vec); @@ -27,7 +26,7 @@ void constFCaller() { === Compliant solution -[source,cpp] +[source,cpp,diff-id=1,diff-type=compliant] ---- void fn(std::vector& vec); void fn(const std::vector& vec); @@ -40,3 +39,6 @@ void constFCaller() { } ---- +== Resources + +* {cpp} reference - https://en.cppreference.com/w/cpp/utility/as_const[std::as_const]