相关疑难解决方法(0)

在定位x86时,C++指针到方法模板推导不会编译,但适用于x64

我有这个示例代码:

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

template<typename T>
struct Gobstopper
{
};

template<>
struct Gobstopper<int(void)>
{
    Gobstopper(int, int) { }    // To differentiate from general Gobstopper template
};

template<typename ClassType, typename Signature>
void DeduceMethodSignature(Signature ClassType::* method, ClassType& instance)
{
    // If Signature is int(), Gobstopper<> should resolve to the specialized one.
    // But it only does on x64!
    Gobstopper<Signature>(1, 2);
}

int main(int argc, char** argv)
{
    A a;
    DeduceMethodSignature(&A::foo, a);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译好 …

c++ templates member-function-pointers member-functions template-argument-deduction

6
推荐指数
1
解决办法
477
查看次数