私はビジュアルスタジオを使用していて、考えられるすべてのことを試しました。しかし、なぜこのコードがエラーを生成するのかわかりません。これが私のコードです。
template <class A,class B> B returnArgtype(void (A::*)(B)) {return *new B;}
struct test
{
void function(int);
decltype(returnArgtype(&test::function)) x;
};
そしてそれはこのエラーを生成します:
error C2784: 'A returnArgtype(void (__thiscall A::* )(B))' : could not deduce template argument for 'void (__thiscall A::* )(B)' from 'void (int)'
そして、パラメータxが関数内で初期化されているときに、次のようなエラーが生成されないのではないかと思います。
struct test
{
void function(int)
{
decltype(returnArgtype(&test::function)) x;
}
};