C++ 11模板别名作为模板模板参数导致不同的类型?

cra*_*ael 9 c++ templates template-templates c++11 template-aliases

我们在编译下面的源代码时发现了一个奇怪的行为:

template<template<class> class TT> struct X { };
template<class> struct Y { };
template<class T> using Z = Y<T>;

int main() {
  X<Y> y;
  X<Z> z;
  z = y; // it fails here
}
Run Code Online (Sandbox Code Playgroud)

这是一个略微修改的示例,取自c ++ 11标准模板别名提案:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf(参见第4页) )另请注意,该提案"声明y和z属于同一类型".因此,在我们的解释中,应该可以从y指定(或复制构造)z.

但是,此代码不使用gcc 4.8.1编译,也不使用clang 3.3编译.这是编译器中的错误还是我们误解了标准?

提前谢谢,craffael等;)

PS Clang错误消息是:

error: no viable overloaded '='

note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'X<template Y>' to 'const X<template Z>' for 1st argument
template<template<class> class TT> struct X { };

note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'X<template Y>' to 'X<template Z>' for 1st argument
template<template<class> class TT> struct X { };
Run Code Online (Sandbox Code Playgroud)

cme*_*erw 11

目前的标准并没有这样说,但意图是y和z具有相同的类型.有一个开放的核心工作组问题:http://wg21.cmeerw.net/cwg/issue1286