Marcel Mueller
2024-05-25 15:57:51 UTC
The emplace functions generally allows to construct container objects
directly at the target location. But std::map expects a value type of
std::pair<const Key, T>. Now the implementation of emplace needs to
instantiate the value type just to get the key to find the insert
location. This cannot happen at the target location, isn't it?
I know, this has been solved in C++17 by try_emplace. I just wonder what
was the idea of this function.
Marcel
directly at the target location. But std::map expects a value type of
std::pair<const Key, T>. Now the implementation of emplace needs to
instantiate the value type just to get the key to find the insert
location. This cannot happen at the target location, isn't it?
I know, this has been solved in C++17 by try_emplace. I just wonder what
was the idea of this function.
Marcel