The boilerplate era: hand-written operator< for ordering, std::hash specializations with ad-hoc combining for unordered keys.
namespace std {
template <> struct hash<Key> {
size_t operator()(const Key& k) const noexcept
{ return hash<int>{}(k.a) ^ (hash<int>{}(k.b) << 1); }
};}
Transparent comparators (std::less<>) enable heterogeneous lookup in ordered containers — compare against string_view/literals without constructing the key type.
No change for authored types; string_view keys make transparent lookup the norm in string-keyed maps.
<=> with = default writes correct, consistent orderings; transparent hashing (P0919) brings heterogeneous lookup to unordered containers too.
struct SvHash {
using is_transparent = void;
size_t operator()(std::string_view s) const noexcept
{ return std::hash<std::string_view>{}(s); }
};
std::unordered_map<std::string, Val, SvHash, std::equal_to<>> m;
m.find("literal");
flat_map/flat_set reuse the same comparator machinery over contiguous storage; nothing new to author.
Reflection makes the generic member-wise hash writable once for all aggregates — the hash_combine-per-type era can end in-house even before the library catches up.
template <class T> std::size_t hash_all(const T& v) {
std::size_t h = 0;
template for (constexpr auto m : nonstatic_data_members_of(^^T))
h = combine(h, v.[:m:]);
return h;
}
C++29direction · not adopted
Direction: a standard hash_combine-style API and reflection-generated comparisons are natural follow-ups under discussion.