- 103 名前:デフォルトの名無しさん mailto:sage [2007/09/30(日) 14:32:36 ]
- svnのboost::function_typesなら関数の型から、戻り値や引数を取りだせるから
それとenable_ifで特殊化してやる方法もある #include <iostream> #include <boost/function_types/result_type.hpp> #include <boost/type_traits.hpp> #include <boost/typeof/typeof.hpp> #include <boost/utility.hpp> void func_v() {} int func() { return 0; } template < typename sig , class Enable = void > struct C { void f() { std::cout << "func\n"; } }; template <typename sig> struct C< sig , typename boost::enable_if< typename boost::is_same< typename boost::function_types::result_type<sig>::type , void>::type>::type > { void f() { std::cout << "void func\n";} }; int main() { C< BOOST_TYPEOF(func_v) >().f(); C< BOOST_TYPEOF(func) >().f(); }
|

|