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
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}`
}
The text was updated successfully, but these errors were encountered:
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
andstd::make_tuple
, so we don't want them anymore(except the case whenstd::reference_wrapper
passed).Bear in mind that this check should not work with generic types, because it's impossible to know is that types are reference wrappers:
The text was updated successfully, but these errors were encountered: