diff options
Diffstat (limited to 'absl/container/internal/hash_policy_traits.h')
-rw-r--r-- | absl/container/internal/hash_policy_traits.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/absl/container/internal/hash_policy_traits.h b/absl/container/internal/hash_policy_traits.h index 86ffd1be..ec08794a 100644 --- a/absl/container/internal/hash_policy_traits.h +++ b/absl/container/internal/hash_policy_traits.h @@ -168,6 +168,9 @@ struct hash_policy_traits : common_policy_traits<Policy> { #endif } + // Whether small object optimization is enabled. False by default. + static constexpr bool soo_enabled() { return soo_enabled_impl(Rank1{}); } + private: template <class Hash> struct HashElement { @@ -183,6 +186,18 @@ struct hash_policy_traits : common_policy_traits<Policy> { return Policy::apply(HashElement<Hash>{*static_cast<const Hash*>(hash_fn)}, Policy::element(static_cast<slot_type*>(slot))); } + + // Use go/ranked-overloads for dispatching. Rank1 is preferred. + struct Rank0 {}; + struct Rank1 : Rank0 {}; + + // Use auto -> decltype as an enabler. + template <class P = Policy> + static constexpr auto soo_enabled_impl(Rank1) -> decltype(P::soo_enabled()) { + return P::soo_enabled(); + } + + static constexpr bool soo_enabled_impl(Rank0) { return false; } }; } // namespace container_internal |