Consider the following code:
#include <iostream>
#include <type_traits>
template <class... Ts>
struct test {
static void foo(const std::remove_reference_t<Ts>&...) {
std::cout << "1\n";
}
template <class... Us>
static void foo(Us&&...) {
std::cout << "2\n";
}
};
int main() {
test<int&, double&>::foo(1, 1.0);
}
The above code prints "2". Why is the second overload considered a better match?
The first one boils down to foo(const int&, const double&) and it's a regular function, so it should be preferred, shouldn't it?
I guess it's not an "exact match", but what is not "exact" here exactly?