As others have said, template aliases are the way to go if you can use C ++ 0x:
template < typename MappedType >
using StringHashMap = stdext::hash_map< std::string, MappedType, CStringHasher >;
StringHashMap< int > mapA;
StringHashMap< bool > mapB;
(As @MSalters noted, if you have C ++ 0x, you should probably use one std::unordered_map.)
Otherwise, you can use the usual workaround, which should define a class template containing typedef:
template < typename MappedType >
struct StringHashMap
{
typedef stdext::hash_map< std::string, MappedType, CStringHasher > type;
};
StringHashMap< int >::type mapA;
StringHashMap< bool >::type mapB;
( SO) , StringHashMap< T >::type typename, , . , FAQ, , . ( @sbi .)