为什么模板别名专门化取决于引用它的上下文? [英] Why a template alias specialization depends on the context in which it is referred?
本文介绍了为什么模板别名专门化取决于引用它的上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑以下示例代码:
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>>
的别名.尽管如此,定义它的事实取决于引用它的上下文.
V<int>::pt
is an alias for pt_type<V<int>>
. Nevertheless the fact it is defined depends on the context where it is referred.
C ++标准在何处说明,在引用别名专门化的上下文中执行了用template参数替换template参数?
Where is it explained in the C++ standard that the substitution of the template parameter by the template argument is performed in the context where is refered the alias specialization?
推荐答案
无处.这是核心问题1554 .
从当前的14.5.7 [temp.alias]措词来看,别名模板和访问控制之间的交互作用尚不清楚.例如:
The interaction of alias templates and access control is not clear from the current wording of 14.5.7 [temp.alias]. For example:
template <class T> using foo = typename T::foo;
class B {
typedef int foo;
friend struct C;
};
struct C {
foo<B> f; // Well-formed?
};
这篇关于为什么模板别名专门化取决于引用它的上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文