次のように、C++でunordered_mapを定義しています。
unordered_map<CustomClass, int, CustomClassHash, CustomClassEq> myMap;
CustomClassEqを正常に定義できたと仮定します。CustomClassのハッシュが欲しいです。クラス内の文字列属性のハッシュに委任するCustomClassHash。CustomClassHashの定義内で文字列クラスのハッシュ関数を再利用できる方法はありますか?
これが私がやりたいことです:
struct CustomClassHash {
long operator()(const CustomClass &c) const {
string s = c.getString();
// TODO: return the hash of s
}
};