std::unordered_map::insert
does not insert a new element if one with the same key already exists.
auto p = book->insert(std::make_pair(a, temp));
std::cout << std::boolalpha;
std::cout << "Did insert succeed? " << p.second << std::endl;
If you want to update an existing element if one exists, use operator[]
:
(*book)[a] = temp;
Note: you don't need to pass pointers, unless you want to allow for the possibility of nullptr
being passed. It is simpler to use references:
void OB::x(std::unordered_map<int,PL>& book, int a, long b) { ... }
x(book_b, a, b);