[Cs3] maps and emplace()
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri Feb 19 11:11:57 EST 2021
CS3 stdudents,
Emplace with maps is and is not straightforward. I came up with
example usage here:
http://antares.cs.kent.edu/~mikhail/classes/cs3/Examples/STLContainersAssociative/mapEmplace.cpp
Some experts (Scott Meyers) endorse emplace() for efficiency, others
(Bjarne Stroustrup) oppose due to safety concerns. C++11 makes certain
efficient things with emplace() rather wordy and it is updated in
C++17 with, what looks to me, even more wordiness.
Here is a detailed discussion on that:
https://www.fluentcpp.com/2018/12/11/overview-of-std-map-insertion-emplacement-methods-in-cpp17/
Thanks,
--
Mikhail
More information about the cs3
mailing list