Template partial specialization for __stdcall function pointer

前端 未结 3 1793
被撕碎了的回忆
被撕碎了的回忆 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:42

    This is because (*) means default calling convention, which is __cdecl.

    template
    class TFunction
    {
      typedef R (*func_type)(T0,T1);
    };
    

    is actually equal to

    template
    class TFunction
    {
      typedef R (__cdecl *func_type)(T0,T1);
    };
    

    which, of course, will not match an R(__stdcall *)(T0, T1) on Win32 where __stdcall is not ignored. If you want to partially specialize for function pointers then you will need a partial spec for every calling convention you want to accept.

提交回复
热议问题