How can I make the map::find operation case insensitive?

前端 未结 11 1851
野的像风
野的像风 2020-12-01 00:23

Does the map::find method support case insensitive search? I have a map as follows:

map > directory;
<         


        
11条回答
  •  北海茫月
    2020-12-01 00:37

    No, you can not do that using find as in that case there will be multiple matches. For example, while inserting lets you have done something like map["A"] = 1 and map["a"] = 2 and now if you want a case insensitive map.find("a") what is the expected return value? The simplest way to solve this would be insert the string into map in only one case (either upper or lower case) and then using the same case while doing the find.

提交回复
热议问题