You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CppCoreCheck rule that enforces C++ Core Guidelines Con.3
C26460 USE_CONST_REFERENCE_ARGUMENTS
The reference argument '%argument%' for function '%function%' can be marked as const (con.3).
Passing an object by reference indicates that the function has the potential modify the object. If that is not the intent of the function, it is better to mark the argument as a const reference.
structMyStruct
{
voidMemberFn1() const;
voidMemberFn2();
};
voidFunction1_Helper(const MyStruct&);
voidFunction1(MyStruct& myStruct) // C26460, see comments below.
{
myStruct.MemberFn1(); // The member function is marked as constFunction1_Helper(myStruct); // Function1_Helper takes a const reference
}
voidFunction2(MyStruct& myStruct)
{
myStruct.MemberFn2(); // MemberFn2 is non-const and has the potential to modify data
}