10 Jan
2023
10 Jan
'23
2:59 p.m.
See `std::map::try_emplace(k, args…)`.
https://en.cppreference.com/w/cpp/container/map/try_emplace
Notes: Unlike insert or emplace, these functions do not move from rvalue arguments if the insertion does not happen.
Yes, however at the callsite you can clearly see the different semantics: "try_" That's much harder for a constructor. Although a well-named factory method might be a solution if this semantic is useful.