heterogeneous mutation for F14 maps and sets
Summary: This diff extends heterogeneous key handling (when the hasher and key equality functor are transparent) to mutating operations. If a key of type K was previously eligible for heterogeneous find and key_type can be constructed from the key, then that construction can be deferred until after it is verified that the key is not previously in the table when using any of the operations that may insert a new element. If the key was already present then this avoids the construction of key_type entirely. Heterogeneous erase is also added in the obvious fashion. Construction of key_type from K can be accomplished without key_type's cooperation by the use of an explicit conversion operator, such as the explicit operator std::string recently added to StringPiece. That means that a F14 map or set with std::string key and transparent StringPiece hash and equality can now use StringPiece natively as a key. Destructuring is applied whenever possible, so the heterogeneous key type K may be found as the first element of a pair (for map insert or emplace) or even inside the first tuple when using map emplace with std::piecewise_construct. This diff adds heterogeneous key support to Map::insert Map::insert_or_assign Map::emplace Map::try_emplace Map::operator[] Set::insert Set::emplace Reviewed By: yfeldblum Differential Revision: D8301887 fbshipit-source-id: 1a45e13739c550f094afe09123839a3c9cd892ff
Showing
This diff is collapsed.
Please register or sign in to comment