Open hwisungi opened 5 months ago
Yes, there is not much cause for slicing concerns in these scenarios of tag-based selection.
Suggestion: warn only if both the base class and the derive class have non-static data members.
suggested to consider an exception to this rule for tag types because:
Tag Types (like Tag
Copying is lightweight: Since Tag
Semantics and design: Tag types are often used as simple identifiers for types or traits, and it's semantically more straightforward to pass them by value. Creating pointers or references to tag types introduces unnecessary complexity without any benefit in performance.
In the original example, what useful action could value() perform? Anything more than "not implemented"?
After fixing a false negative bug in msvc code analysis, some library code were newly tagged for violations of ES.63 rule. One of the patterns that received those warnings was brought to our attention as potential candidate of exception to the rule. Here is the pattern:
Serving as a tag type, Tag does not need any data from the source object to perform its operations. Thus, it should be more efficient for a new instance of T to be created from the source object than creating a pointer / reference to the source object.
So, it was suggested to add an exception for this pattern to rule ES.63.