2011-08-18から1日間の記事一覧
以下のようにテンプレートテンプレートパラメータを受け取るテンプレートクラスがあるとします。 template< typename T, typename U, template<typename, typename> class Pred = boost::is_same > struct equal{ typedef Pred<T, U> type; }; // OK BOOST_MPL_ASSERT(( equal<int, int> )); // O</int,></t,></typename,>…
static_cast を使用して取得出来たんですね……。 [ソース] #include <iostream> void func(int a){ std::cout << a << std::endl; } void func(float a){ std::cout << a << std::endl; } void func(float a, int b){ std::cout << a << ":" << b << std::endl; } int m</iostream>…
こんな使い方も出来たんですね、知りませんでした。 [ソース] #include <boost/variant.hpp> #include <boost/lexical_cast.hpp> #include <string> typedef boost::variant<int, float, std::string> object_type; struct equal : boost::static_visitor<bool>{ bool operator ()(float a, int b) const{ return a == static_cast<float>(b); } bool o…</float></bool></int,></string></boost/lexical_cast.hpp></boost/variant.hpp>