The documentation for both containers
say that emplace() function constructs elements in place,
but how do they know the location of the new element before the element is constructed?
For example,
unordered_set places elements according to their hash
value. How does the unordered_set know the hash value of
the element before it is constructed?
I thought
maybe the emplace function is meant to take rvalues,
calculate the position of the new element and just move the object, but then
insert() can do the same thing.
No comments:
Post a Comment