std::inserter suffers from problem that it calls insert that for map is noop if key already exists. There is std::map::insert_or_assign, but I was unable to find an inserter that uses that.
Is there something like this in C++20?
note: I know I can c/p it from somewhere on the SO/internet, I am interested in STL/boost solutions, not c/p implementation from somewhere.
No, there is no corresponding inserter that use insert_or_assign
. In fact, the wording explicitly says there are only 3 such functions:
back_inserter, front_inserter, and inserter are three functions making the insert iterators out of a container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With