How do I allow the STL implementation to pick up my custom types? On MSVC, there is a class std::tr1::hash
, which I can partially specialize by using
namespace std
{
namespace tr1
{
template <>
struct hash<MyType>
{ ... };
}
}
but is this the recommended way? Moreover, does this work with GCC's implementation as well? For boost::hash
, it's enough to provide a free function size_t hash_value (const MyType&)
, is there something similar for the TR1 implementation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…