There is not a universal priority between these two functions. They compete equally in the overload resolution algorithm. In general the so-called "universal reference" wins unless const T&
is an exact match, and there the const T&
wins.
struct A {};
int
main()
{
f(std::declval<A>()); // calls f<A>(A&&), #1
f(std::declval<const A>()); // calls f<const A>(const A&&), #1
f(std::declval<A&>()); // calls f<A&>(A&), #1
f(std::declval<A&&>()); // calls f<A>(A&&), #1
f(std::declval<const A&&>()); // calls f<const A>(const A&&), #1
f(std::declval<const A&>()); // calls f<A>(const A&), #2
}
Good advice is to never overload like this.