Skip to content

Exception to ES.63 for base type without any data member #2206

Open
@hwisungi

Description

@hwisungi

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:

    template<typename T>
    struct Tag { /* No data member */ };

    template<typename T>
    constexpr int value(Tag<T>);

    template<typename T>
    struct S : Tag<T> {
        int x;
    };

    template<typename T>
    void f() {
        S<T> s;
        value(s);
    }

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions