gpt4 book ai didi

c++ - C++ 中的参数相关名称查找 : point from n3290 Draft

转载 作者:行者123 更新时间:2023-11-30 00:58:13 25 4
gpt4 key购买 nike

来自 ISO C++ DRAFT n3290 的一点:参数相关名称查找:第 3.4.2 节,第 2 段,

For each argument type T in the function call, there is a set of zero or more associated namespaces and a set 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-declaration s 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 namespace and classes are both empty.

— 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 classes of which any member templates used as template template arguments are
members.

[ Note: Non-type template arguments do not contribute to the set of a associated namespaces. — end note ]

任何人都可以用一个例子来解释这个......请

在上面的语句中“命名空间和类集都是空的”..这怎么可能?

在第 2 点,他说了更多...请任何人解释一下?

最佳答案

基本类型,如 intchar , 未在任何命名空间或类中定义。这就是为什么他们的关联列表将为空。

如果函数参数是从模板创建的类型,则不仅要考虑该模板的命名空间,还要考虑其模板参数的命名空间。例如,如果您有一个 std::vector<foo::bar>作为参数,命名空间集将包括 stdfoo .

关于c++ - C++ 中的参数相关名称查找 : point from n3290 Draft,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6855409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com