-
Notifications
You must be signed in to change notification settings - Fork 15k
Open
Feature
Copy link
Labels
c++17check-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidy
Description
C++17 suggests us a way to invoke templated class constructor without explicit template arguments specification.
Without that feature we had to use special wrappers like std::make_pair and std::make_tuple, so we don't want them anymore(except the case when std::reference_wrapper passed).
extern int a;
extern int b;
auto t1 = std::make_tuple(a, b); // INCORRECT
auto t2 = std::tuple{a, b}; // OK
auto p1 = std::make_pair(a, b); // INCORRECT
auto p2 = std::pair{a, b}; // OK
auto t3 = std::make_tuple(std::ref(a), b); // OK because of `std::reference_wrapper`
auto p3 = std::make_pair(std::cref(a), b); // OK the same reason
Bear in mind that this check should not work with generic types, because it's impossible to know is that types are reference wrappers:
template<typename T>
void process(T a, int b) {
auto p1 = std::make_pair(a, b); // OK
auto p2 = std::make_pair(static_cast<int>(a), b); // INCORRECT, should be changed to `std::pair{static_cast<int>(a), b}`
}
Metadata
Metadata
Assignees
Labels
c++17check-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidy