Template引数に関数のシグネチャを渡した時の各パラメータ

Templateの引数に関数のシグネチャとか関数型を渡したときに、戻り値とか引数とかをそれぞれ取得する方法を知らなかった。取得する方法というかそのもととなる方法というか。

template<typename Signature>
struct func_sig;

template<typename R, typename A1, typename A2>
struct func_sig<R(A1, A2)>
{
    typedef R result_type;
    typedef A1 arg1_type;
    typedef A2 arg2_type;
};
#include <string>
#include <vector>

#include <boost/type_traits.hpp>
#include <boost/static_assert.hpp>

int main()
{
    typedef void foo_t(std::string, std::vector<int>);

    BOOST_STATIC_ASSERT((boost::is_same<func_sig<int(char, double)>::result_type, int>::value));
    BOOST_STATIC_ASSERT((boost::is_same<func_sig<int(char, double)>::arg1_type, char>::value));
    BOOST_STATIC_ASSERT((boost::is_same<func_sig<int(char, double)>::arg2_type, double>::value));

    BOOST_STATIC_ASSERT((boost::is_same<func_sig<foo_t>::result_type, void>::value));
    BOOST_STATIC_ASSERT((boost::is_same<func_sig<foo_t>::arg1_type, std::string>::value));
    BOOST_STATIC_ASSERT((boost::is_same<func_sig<foo_t>::arg2_type, std::vector<int> >::value));
}

こんなふうにすればよかったのか。。。

参考