n3290 的一点:依赖于参数的名称查找
n3290 ISO 标准草案中的一点:第 3.4.2 节,第二点
For each argument type T in the function call, there is a set of zero or
more associated namespaces and aset of zero or more associated classes to
be considered. The sets of namespaces and classes is determined entirely
by the types of the function arguments (and the namespace of any template
template argument).Typedef names and using-declarations used to specify
the types do not contribute to this set. The sets of namespaces and
classes are determined in the following way:
— If T is a fundamental type, its associated sets of namespaces and
classes are both empty. ##1st point
— If T is a class type (including unions), its associated classes are:
the class itself; the class of which it is a member, if any; and its
direct and indirect base classes. Its associated namespaces are the
namespaces of which its associated classes are members. Furthermore,
if T is a class template specialization, its associated namespaces and
classes also include: the namespaces and classes associated with the
types of the template arguments provided for template type parameters
(excluding template template parameters); the namespaces of which any
template template arguments are members; and the classesof which any
member templates used as template template arguments are members.
[ Note: Non-type template arguments do not contribute to the set of
associated namespaces.—end note ] ##2nd point
— If T is an enumeration type, its associated namespace is the namespace
in which it is defined. If it is class member, its associated class is
the member’s class; else it has no associated class. ##3rd point
— If T is a pointer to U or an array of U, its associated namespaces and
classes are those associated with U. ##4th point
— If T is a function type, its associated namespaces and classes are
those associated with the function parameter types and those associated
with the return type. ##5th point
— If T is a pointer to a member function of a class X, its associated
namespaces and classes are those associated with the function parameter
types and return type, together with those associated with X.
— If T is a pointer to a data member of class X, its associated namespaces
and classes are those associated with the member type together with those
associated with X. ##6th point
If an associated namespace is an inline namespace (7.3.1), its enclosing
namespace is also included in the set. If an associated namespace directly
contains inline namespaces, those inline namespaces are also included in
the set. In addition, if the argument is the name or address of a set of
overloaded functions and/or function templates, its associated classes
and namespaces are the union of those associated with each of the members of
the set, i.e., the classes and namespaces associated with its parameter
types and return type. Additionally,if the aforementioned set of overloaded
functions is named with a template-id, its associated classes and namespaces
also include those of its type template-arguments and its template
template-arguments.
,我理解第二点、第三点和第二点。第六点..任何人都可以尝试举一些例子..来理解另一点..请用例子解释一下?
在第二点中,他还给出了一个注释:“非类型模板参数不会对关联的命名空间集做出贡献”..也解释一下这一点......?
A point from n3290 Draft ISO Standard:Section : 3.4.2 ,Point 2nd
For each argument type T in the function call, there is a set of zero or
more associated namespaces and aset of zero or more associated classes to
be considered. The sets of namespaces and classes is determined entirely
by the types of the function arguments (and the namespace of any template
template argument).Typedef names and using-declarations used to specify
the types do not contribute to this set. The sets of namespaces and
classes are determined in the following way:
— If T is a fundamental type, its associated sets of namespaces and
classes are both empty. ##1st point
— If T is a class type (including unions), its associated classes are:
the class itself; the class of which it is a member, if any; and its
direct and indirect base classes. Its associated namespaces are the
namespaces of which its associated classes are members. Furthermore,
if T is a class template specialization, its associated namespaces and
classes also include: the namespaces and classes associated with the
types of the template arguments provided for template type parameters
(excluding template template parameters); the namespaces of which any
template template arguments are members; and the classesof which any
member templates used as template template arguments are members.
[ Note: Non-type template arguments do not contribute to the set of
associated namespaces.—end note ] ##2nd point
— If T is an enumeration type, its associated namespace is the namespace
in which it is defined. If it is class member, its associated class is
the member’s class; else it has no associated class. ##3rd point
— If T is a pointer to U or an array of U, its associated namespaces and
classes are those associated with U. ##4th point
— If T is a function type, its associated namespaces and classes are
those associated with the function parameter types and those associated
with the return type. ##5th point
— If T is a pointer to a member function of a class X, its associated
namespaces and classes are those associated with the function parameter
types and return type, together with those associated with X.
— If T is a pointer to a data member of class X, its associated namespaces
and classes are those associated with the member type together with those
associated with X. ##6th point
If an associated namespace is an inline namespace (7.3.1), its enclosing
namespace is also included in the set. If an associated namespace directly
contains inline namespaces, those inline namespaces are also included in
the set. In addition, if the argument is the name or address of a set of
overloaded functions and/or function templates, its associated classes
and namespaces are the union of those associated with each of the members of
the set, i.e., the classes and namespaces associated with its parameter
types and return type. Additionally,if the aforementioned set of overloaded
functions is named with a template-id, its associated classes and namespaces
also include those of its type template-arguments and its template
template-arguments.
here i understood the 2nd,3rd & 6th point..can any one try to give some exaples ..to understand the other point ..please explain with an example ?
And also in 2nd point he gave a note :"Non-type template arguments do not contribute to the set of associated namespaces" ..explain this also ...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它解释了如何根据函数的参数来查找函数。
1) 基本类型不是命名空间或类的成员,因此它们没有贡献。
2b) 非类型模板参数是值并且没有贡献。
4) 如果类型是 T* 或 T[],则将其视为 T。
5) 如果参数是另一个函数,则递归搜索其关联的命名空间或类。
It explains how you look for a function based on its parameters.
1) Fundamental types are not members of a namespace or class, so they don't contribute.
2b) non-type template parameters are values and don't contribute.
4) If the type is T* or T[], treat that like it was just T.
5) If the parameter is another function, recurse the search for its associated namespaces or classes.