何时将特征作为模板参数传递而不是仅使用某些现有的特征结构,例如
我有一些瓷砖类,我想要它们具有一些共同点(特征),因此我设计了
设计特征本身是否被视为“特征blob(traits-blob)”?
typedef basic_ofstream< char, char_traits<char> >
与
typedef basic_ofstream< char >
相比较实用?我有一些瓷砖类,我想要它们具有一些共同点(特征),因此我设计了
tile_traits
来包含有关瓷砖的所有基本信息,例如int_type
和flag_type
,如下所示://unspecialized
template<typename T> struct tile_traits;
//... other stuff here, declaration of a tile class
template<>
struct tile_traits<tile_class>
{
typedef tile_class::int_type int_type;
typedef tile_class::flag_type flag_type;
//other possible tile info here.
}
设计特征本身是否被视为“特征blob(traits-blob)”?