A transparent adapter to facilitate the is_transparent protocol
Summary: [Folly] A `transparent` adapter to facilitate the `is_transparent` protocol. Compare types with member type or member alias `is_transparent` may be used to enable heterogeneous lookup in ordered containers which support it, such as `std::set` and `std::map` as of C++14, and `folly::sorted_vector_set` and `folly::sorted_vector_map`. In some cases, nothing more is required than to add that `is_transparent` member to an existing compare type - `folly::transparent` may facilitate such cases. Example: ```lang=c++ using TransparentStringPieceLess = folly::transparent<std::less<folly::StringPiece>>>; std::map<std::string, float, /* Compare = */ TransparentStringPieceLess> m; m["somekey"] = 12.; m.find(folly::StringPiece("somekey"))->second = 13.; // heterogeneous lookup ``` To demonstrate the example, rewrite the `folly::sorted_vector_set` and `folly::sorted_vector_map` transparent-lookup tests. Reviewed By: ot Differential Revision: D6921862 fbshipit-source-id: 306ff1f6f178ae29ac80ee7cd28595b80fc393d1
Showing
Please register or sign in to comment