How to check if std::map contains a key without doing insert?

后端 未结 3 1587
遥遥无期
遥遥无期 2020-12-04 08:26

The only way I have found to check for duplicates is by inserting and checking the std::pair.second for false, but the problem is that this still i

3条回答
  •  鱼传尺愫
    2020-12-04 08:57

    Your desideratum,map.contains(key), is scheduled for the draft standard C++2a. In 2017 it was implemented by gcc 9.2. It's also in the current clang.

提交回复
热议问题