イディオム

戻り値で SFINAE

#include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_integral.hpp> template<typename T> void func(T, typename boost::enable_if<boost::is_integral<T> >::type* = 0 ){} // 戻り値型は、enable_if の第二引数 template<typename T> typename boost::enable_if<boost::is_integral<T>, void>::type func2(T){}…</boost::is_integral<t></typename></boost::is_integral<t></typename></boost/type_traits/is_integral.hpp></boost/utility/enable_if.hpp>

PImpl

PImpl イディオムは、ヘッダー内での include 数を減らしたい場合や実装を隠蔽する時に使用されるイディオムです。 id:melpon さんの C++ でのビルド時間を短縮するいくつかの方法 にチラッと出てきたアレです。 便乗ヒャッホイ そういえばあんまり使ったこ…

ダブルディスパッチ

なにやら難しい言葉だがやってる事は簡単である。 struct Zaku{}; struct Char_zaku : public Zaku{}; struct Gundam{ void say(const Zaku&) const{ std::cout << "相手がザクなら!人間じゃないんだ、ぼくだって" << std::endl; } void say(const Char_zak…