diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 4d411b31..7c9150ba 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -722,6 +723,22 @@ namespace boost { #endif +//////////////////////////////////////////////////////////////////////////// +// Type checkers used for the transparent member functions added by C++20 and up + + template + struct make_dependent : public true_type {}; + + template struct is_transparent : public false_type + { + }; + + template + struct is_transparent::type> : public true_type + { + }; + //////////////////////////////////////////////////////////////////////////// // Explicitly call a destructor diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index aed6619b..7e6dd467 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -757,7 +757,12 @@ namespace boost { size_type count(const key_type&) const; - template size_type count(const TransparentKey&) const; + template + typename boost::enable_if_c::value && + detail::is_transparent::value && + detail::is_transparent

::value, + size_type>::type + count(const Key&) const; std::pair equal_range(const key_type&); std::pair equal_range( @@ -1840,9 +1845,12 @@ namespace boost { } template - template - typename unordered_map::size_type - unordered_map::count(const TransparentKey& k) const + template + typename boost::enable_if_c::value && + detail::is_transparent::value && + detail::is_transparent

::value, + typename unordered_map::size_type>::type + unordered_map::count(const Key& k) const { std::size_t const key_hash = table::policy::apply_hash(this->hash_function(), k);