次のコードを使用して、特定の関数への長い引数を検出しました。
したがって、与えられた:
int f(int *) { return 0; }
抽出したいint *
。
これが私の試みです:
template<class T, class U> struct SingleArg {
typedef U MyArg;
};
template<class T, class U> SingleArg<T, U> fT(T (*p)(U));
int main() {
std::result_of<decltype(fT(f))>::type::MyArg t;
}
ただし、これは機能せず、gcc 4.6 でエラーが発生します
> error: std::result_of<SingleArg<int, int*> >::type has not been
> declared
だから、私は2つの質問があります:
a) 上記のコードの何が問題になっていますか?
b) 他の方法でこれを行うことは可能ですか?