Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
の実際の実装をC++ 11std::hashの独自の定義に置き換えることができますか?std::hash
std::hash
標準ライブラリには触れずに、私のコードベースからという意味です。
この場合、仮想関数/ポリモーフィズムの使用は見られないので、とにかく std::hash の定義を変更できないと思いますか?
特定のタイプのハッシュを特殊化できます。こことここを参照してください。たとえば、このように
namespace std { template <> struct hash<Foo> { size_t operator()(const Foo & x) const { /* your code here, e.g. "return hash<int>()(x.value);" */ } }; }
既存のバージョンのライブラリ実装者よりもうまくやれると思うなら、あなたは 1. 間違っているか、2. 賢いかのどちらかです。