【初心者歓迎】C/C++室 Ver.43【環境依存OK】
■ このスレッドは過去ログ倉庫に格納されています
0103デフォルトの名無しさん
2007/09/30(日) 14:32:36それと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();
}
■ このスレッドは過去ログ倉庫に格納されています