如何使用自定义比较器仅在 std::map 中进行搜索?

How to only make searching in std::map using a custom comparator?

我希望 std::map 仅在搜索时使用比较器,例如其余操作包括插入操作必须使用默认操作。可能吗?

I want the std::map to use the comparator only while searching ... Is it possible?

好吧,您可以使用任何您想要的比较器在地图上进行线性搜索。但这不会像使用地图具有的搜索树结构那样快,搜索树结构是使用地图的比较器构建的。

I have a map with keys that are regular expressions (represented by strings). So when I want to find some value by the key, the map must check if the key matches to one of the map's regular expression.

看来线性搜索确实是你所需要的。