C++ pointer-to-method template deduction doesn't compile when targeting x86, but works with x64

后端 未结 1 423

I\'ve got this sample code:

struct A
{
    int foo() { return 27; }
};

template
struct Gobstopper
{
};

template<>
struct Gobstopper         


        
1条回答
  •  广开言路
    2021-01-05 14:03

    You are quite correct. The type of Signature with a Win32 target is int __thiscall(void) while on x64 it is int __cdecl(void). Note that on either target the type of non-member functions commonly called int(void) is indeed int __cdecl(void) so, by coincidence one of the constructed types actually (not really correctly!) matches.

    In general it is not advisable to mix the different types of function pointers by template magic, so the Gobstopper specialization should look at something like int (ClassType::*)() instead.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题