Assume the following example
using namespace std;
template <template <typename> class>
struct X
{
X()
{
std::cout << "1";
}
};
template <typename>
struct Y {};
template <typename T>
using Z = Y<T>;
template <>
struct X<Y>
{
X()
{
std::cout << "2";
}
};
int main()
{
X<Y> x1;
X<Z> x2;
}
The expression X<Y> x1
it is clear that is use the specialization that prints "2"
The second one is strange. Doing analysis the X<Z>
is translated to X< Y < T > >
. I expect to print "1" . But running the code this prints "2". Which rule is applied in the second one?
Aucun commentaire:
Enregistrer un commentaire