There's a version of map.insert
that takes two iterators. An insert fails if the item (key) is already present in the target map, so this does exactly what you want.
#include <iostream>
#include <map>
int main() {
std::map<char, int> stuff;
stuff['a'] = 1;
stuff['b'] = 2;
std::map<char, int> stuff2;
stuff2['b'] = 3;
stuff2['c'] = 4;
stuff.insert(stuff2.begin(), stuff2.end());
for (auto i : stuff)
std::cout << i.first << "\t" << i.second << "\n";
}
Result:
a 1
b 2
c 4