Template partial specialization for __stdcall function pointer

前端 未结 3 1791
被撕碎了的回忆
被撕碎了的回忆 2021-02-15 14:41
typedef bool (*my_function_f)(int, double);
typedef bool (__stdcall *my_function_f2)(int, double);
//            ^^^^^^^^^

template class TFunction;

tem         


        
3条回答
  •  时光说笑
    2021-02-15 14:54

    No, this is by design. The calling convention is very much part of the function declaration, your template function uses the default calling convention. Which is not __stdcall unless you compile with /Gz. The default is /Gd, __cdecl.

    The code compiles when you target x64 because it blissfully has only one calling convention.

    Fix:

    template
    class TFunction
    {
        // etc..
    };
    

提交回复
热议问题