Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there assign_or_inserter/insert_or_assigner in C++20?

Tags:

c++

stdmap

c++20

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.

like image 691
NoSenseEtAl Avatar asked Dec 11 '22 00:12

NoSenseEtAl


1 Answers

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.

like image 184
cigien Avatar answered Dec 30 '22 18:12

cigien