以下のように std::map で比較をカスタマイズします。
class my_cmp {
public:
bool operator()(const string &a, const string &b) {
return (a.length() >= b.length());
}
};
map<string, int, tmp_cmp> tmp;
文字列の長さごとにソートされたすべてのキーでうまく機能します。しかしtmp.erase("a string");
、もはや機能しません。比較をカスタマイズした後も std::map::erase(key_type) を機能させる解決策はありますか?