I'm using visual studio and I've tried every thing I could think of. but don't know why this piece of code generates error, this is my code:
template <class A,class B> B returnArgtype(void (A::*)(B)) {return *new B;}
struct test
{
void function(int);
decltype(returnArgtype(&test::function)) x;
};
and it generates this error :
error C2784: 'A returnArgtype(void (__thiscall A::* )(B))' : could not deduce template argument for 'void (__thiscall A::* )(B)' from 'void (int)'
and I'm wondering it doesn't generate that error when parameter x is initializing inside a function, something like this:
struct test
{
void function(int)
{
decltype(returnArgtype(&test::function)) x;
}
};