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
std::pair.second
false
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.
map.contains(key)