Seasons.NET

ちょっとした技術ブログです

template

Modern C++ Design勉強日記 クラステンプレートの特殊化は、パターンマッチのようにつかえる

#include "stdafx.h" using namespace std; // Widget class Widget { }; // Widget2 class Widget2 { }; /*------------------------------------------------------------------------- */ /* (1) */ /*-------------------------------------------------…

Modern C++ Design勉強日記 似ているようで違う型

template< int T > struct Int2Type { enum { value = T }; }; #ifdef __TEST_TMP1_1 AUTO_TEST( tmp1_1 ) { Int2Type< true > t; Int2Type< false > f; // tとfは、別の型です。 // それぞの値を表示 cout << t.value << endl; cout << f.value << endl; //…

Coding Guidelines for Integral Constant Expressions

記事 テンプレート勉強するなら必須ですなぁ〜。

Modern C++ Design

Modern C++ Design勉強日記 テンプレートでポリシーを使おう!!(1) Modern C++ Design勉強日記 似ているようで違う型 Modern C++ Design勉強日記 クラステンプレートの特殊化は、パターンマッチのようにつかえる

Modern C++ Design勉強日記 テンプレートでポリシーを使おう!!(1)

動作、構造の専門を受け持つ(ポリシー)を用いることで、それを継承したホスト側を いつでも変更させることができるのがポリシーを使うメリット。 通常の継承では継承の種類が増える程、クラスを実装しなくてはいけないですが、 テンプレートを使えば、テン…