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
When a class with a const ref member inherits a class that deletes move/copy constructors and assignment operators cppcoreguidelines-avoid-const-or-ref-data-members still points out the ref member. This is not an unusual technique (e.g. inheriting from boost::noncopyable). I have written a test case on Compiler Explorer that you can tweak using the #defines.
If the derived class is not a template the check works as expected. If the class is a template but deletes deletes the move/copy constructors and assignment operators itself also works as expected.
Summary:
Is template
Inherits
False positive
Yes
Yes
Yes
Yes
No
No
No
Yes
No
Also, if the derived class is a template and inherits and deletes the constructors/operators anyway it works as expected. But this is presumably a "sub-case" of the non-inheriting case.