QingYun
QingYun

Reputation: 869

Partial specialization with member function type

I want to convert int __stdcall A::(int, int) to int __stdcall (A*, int, int).

My code is

class A {
public:
    int __stdcall B(int, int);
};

template<typename C, typename P1, typename P2>
struct Mem2Normal<int __stdcall C::(P1, P2)> {
    typedef int __stdcall (C*, P1, P2) type;
}; 

Mem2Normal<decltype(A::B)>::type

It caused a lot of syntax errors, how to fix it?

Upvotes: 1

Views: 83

Answers (1)

dyp
dyp

Reputation: 39101

For function pointers, the following works:

class A {
public:
    int __stdcall B(int, int);
};

template<typename>
struct Mem2Normal;

template<typename C, typename P1, typename P2>
struct Mem2Normal<int (__stdcall C::*)(P1, P2)> {
    typedef int __stdcall type(C*, P1, P2);
};

int main()
{
    Mem2Normal<decltype(&A::B)>::type x;
}

Upvotes: 3

Related Questions