小编Fla*_*een的帖子

std :: is_unsigned是否意味着std :: is_integral

如果我需要一种满足std::is_unsignedstd::is_integral,我必须同时检查或只std::is_unsigned

c++ type-traits

6
推荐指数
1
解决办法
190
查看次数

c ++普通查找与参数依赖查找

考虑http://en.cppreference.com/w/cpp/language/adl中描述的此示例:

namespace A {
      struct X;
      struct Y;
      void f(int);
      void g(X);
}

namespace B {
    void f(int i) {
        f(i);   // calls B::f (endless recursion)
    }
    void g(A::X x) {
        g(x);   // Error: ambiguous between B::g (ordinary lookup)
                //        and A::g (argument-dependent lookup)
    }
    void h(A::Y y) {
        h(y);   // calls B::h (endless recursion): ADL examines the A namespace
                // but finds no A::h, so only B::h from ordinary lookup is used
    }
}
Run Code Online (Sandbox Code Playgroud)

我想知道为什么出现歧义,因为如果不考虑ADL规则

"由通常的非限定查找生成的查找集包含以下任何内容".

这里B …

c++ name-lookup argument-dependent-lookup

3
推荐指数
1
解决办法
172
查看次数