考虑这个示例代码:
template <class T>
using pt_type = typename T::type;
template <class T>
class V {
using type = int;
public:
using pt = pt_type<V>;
};
void g() {
V<int>::pt a; // Does compile
pt_type<V<int>> b; // Does not compile
}
V<int>::pt
是 pt_type<V<int>>
的别名。然而,它被定义的事实取决于它被引用的上下文。在 C++ 标准 中哪里解释了模板参数替换模板参数是在引用别名特化的上下文中执行的?
最佳答案
无处。这是 core issue 1554 。
关于c++ - 为什么模板别名特化取决于引用它的上下文?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48453343/