☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

对模板函数进行非良构调用,或在模板定义和实例化上下文之外有更好的候选函数匹配

C++-Undefined-Behavior-66
目录 › next › previous

示例:

namespace N
{
    struct A {};

    template <class T>
    void foo(T&, double) { .... }
}

int main()
{
    N::A a;
    foo(a, 1);
}

namespace N
{
    template <class T>
    void foo(T&, int) { .... }   // Undefined behavior, a better match for ‘foo(a, 1)’
}

依据

ISO/IEC 14882:2003 14.6.4.2(1)-undefined ISO/IEC 14882:2011 14.6.4.2(1)-undefined
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.