Skip to content

[clang-tidy] Check request: readability-avoid-enable-if #126987

@denzor200

Description

@denzor200

Needs a check that will find redundant usage of std::enable_if and will suggest more simplified overloading without SFINAE at all.
For example, in 90% usages of std::is_same type trait in a cooperation with std::enable_if we don't really want it.

Look at the sample below...

template<typename T>
std::enable_if<std::is_same<T, int>::value>::type process(T value) {
    // int's implementation..
}

template<typename T>
std::enable_if<!std::is_same<T, int>::value>::type process(const T& value) {
    // generic implementation..
}

...which might be changed to:

void process(int value) {
    // int's implementation..
}

template<typename T>
void process(const T& value) {
    // generic implementation..
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions