Say I have a class template with some specializations
template<typename T> struct A {};
template<typename T> struct A<T const> {};
template<typename T> struct A<T &> {};
Which specialization has the precedence, when I instantiate A<const int&>?
I ran a test with GCC, and it picks the int& specialization. I assume this is the rule, but I can't find where this is stated.
Edit: I was making a mistake considering that const int& matches const T for T=int&, since templates are more than a mere "macro substitution". In particular, it makes no sense to talk about a const reference (only reference to const). Both the current answers helped me figure it out. Unfortunately, I can only pick one as accepted answer, but thank you both.