efficient way to get key from std::map value

后端 未结 4 1961
旧时难觅i
旧时难觅i 2021-01-18 00:46

I have a map as below :

std::map< std::string ,int> mapobj;
mapobj[\"one\"] = 1;
mapobj[\"two\"] = 2;
mapobj[\"three\"] =3 ;

how to g

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 01:15

    I do notice that this has the "stdmap" tag, so this may not be appropriate. However Boost has boost::bimap<> which will allow you to do what you want: it allows lookup by either key or value.

提交回复
热议问题