[temp.spec]/6 的起源故事?
Origin story of [temp.spec]/6?
[temp.spec]/6 读取:
The usual access checking rules do not apply to names in a declaration of an explicit instantiation or explicit specialization, with the exception of names appearing in a function body, default argument, base-clause, member-specification, enumerator-list, or static data member or variable template initializer. [ Note: In particular, the template arguments and names used in the function declarator (including parameter types, return types and exception specifications) may be private types or objects that would normally not be accessible. — end note ]
这条规则背后的动机是什么?哪个提案引入了它(或者它是古老的?),为什么?
添加此措词是为了解决 N0841(自 1996 年起)的问题 6.40:
6.40 Clarication of access checkin in explicit instantiation directives.
This issue and its resolution are from Bill Gibbons' reflector posting c++std-ext-3258.
Status: Open
Bill Gibbons raised the issue that it is not possible to explicitly instantiate templates where the template arguments or other components of the explicit instantiation directive reference types that are not accessible.
namespace N {
template <class T> void f(T);
}
namespace M {
class A {
class B {};
void f() {
B b;
N::f(b);
}
};
}
template void N::f(M::A::B); // should be allowed
问题提示措辞
The usual access checking rules do not apply to explicit instantiations. In particular,
the template arguments, and names used in the function declarator (e.g., including
parameter types, return types, and exception specifications) may be private types or
objects which would normally not be accessible and the template may be a member
template or member function which would not normally be accessible.
随后被采纳为 N0892 的一部分,并且自 C++98 以来一直是规则。
[temp.spec]/6 读取:
The usual access checking rules do not apply to names in a declaration of an explicit instantiation or explicit specialization, with the exception of names appearing in a function body, default argument, base-clause, member-specification, enumerator-list, or static data member or variable template initializer. [ Note: In particular, the template arguments and names used in the function declarator (including parameter types, return types and exception specifications) may be private types or objects that would normally not be accessible. — end note ]
这条规则背后的动机是什么?哪个提案引入了它(或者它是古老的?),为什么?
添加此措词是为了解决 N0841(自 1996 年起)的问题 6.40:
6.40 Clarication of access checkin in explicit instantiation directives.
This issue and its resolution are from Bill Gibbons' reflector posting c++std-ext-3258.
Status: Open
Bill Gibbons raised the issue that it is not possible to explicitly instantiate templates where the template arguments or other components of the explicit instantiation directive reference types that are not accessible.namespace N { template <class T> void f(T); } namespace M { class A { class B {}; void f() { B b; N::f(b); } }; } template void N::f(M::A::B); // should be allowed
问题提示措辞
The usual access checking rules do not apply to explicit instantiations. In particular, the template arguments, and names used in the function declarator (e.g., including parameter types, return types, and exception specifications) may be private types or objects which would normally not be accessible and the template may be a member template or member function which would not normally be accessible.
随后被采纳为 N0892 的一部分,并且自 C++98 以来一直是规则。