明示的なクラステンプレートの特殊化と別の部分的なクラステンプレートの特殊化を備えたクラステンプレートがあります。
template< typename T1, typename T2 >
class A{
internal_representation1 inRep;
// methods
};
template<>
class A < specific_type_1,specific_type_2 >{
//internal represenation different for this type.
internal_representation2 inRep;
// methods
};
template< template T1 >
class A < T1,specific_type_2 >{
//internal represenation different for this type.
internal_representation3 inRep;
// methods
};
特殊化により、インターフェイスが重複します。クラステンプレートとその特殊化はすべて同じメソッド名を持ちますが、実装が異なります。具体的には、内部データ構造の表現です。
上記の実装をブリッジデザインパターンに置き換える必要がありますか?
注:この質問は、boost ::mplを使用してBuilderデザインパターンを実装するにはどうすればよいですか?に関連しています。