次のタイプ:
std::remove_pointer<int(*)(int)>::type
ですint(int)
。このコード:
#include <iostream>
#include <type_traits>
using namespace std;
int main()
{
cout << boolalpha;
cout << is_same<remove_pointer<int(*)(int)>, int(int)>::value;
cout << endl;
}
「真」を出力します。しかし、「関数メンバー」の(書かれた)型は何ですか?
#include <iostream>
#include <type_trais>
using namespace std;
struct A {};
int main()
{
cout << boolalpha;
cout << is_same<remove_pointer<int(A::*)(int)>, int(int)>::value;
cout << endl;
}
戻りますfalse
。そしてint A::(int)
、コンパイルエラー(無効なタイプ)をスローするようなものです。