小编Ang*_*ham的帖子

Bizarre template errors when compiling in Visual C++ with /permissive-

I'm trying to compile some code in VS2019 with /permissive- that involves both templates and overloading and wierd things are happening. (https://godbolt.org/z/fBbQu6)

As in the godbolt, when my templateFunc() is declared between two overloads like so:

namespace Foospace {
    class A;
    void func(A*) {};

    template<class T> void templateFunc() { Foospace::func((T*)0); }

    class B;
    void func(B*) {};

    void func() { Foospace::templateFunc<B>(); }
}
Run Code Online (Sandbox Code Playgroud)

I get error C2664: 'void Foospace::func(Foospace::A *)': cannot convert argument 1 from 'T *' to 'Foospace::A …

c++ templates visual-studio

7
推荐指数
2
解决办法
190
查看次数

标签 统计

c++ ×1

templates ×1

visual-studio ×1