@@ -600,6 +600,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
600600# include < __memory/addressof.h>
601601# include < __memory/allocator.h>
602602# include < __memory/allocator_traits.h>
603+ # include < __memory/compressed_pair.h>
603604# include < __memory/pointer_traits.h>
604605# include < __memory/unique_ptr.h>
605606# include < __memory_resource/polymorphic_allocator.h>
@@ -643,34 +644,9 @@ _LIBCPP_PUSH_MACROS
643644
644645_LIBCPP_BEGIN_NAMESPACE_STD
645646
646- template <class _Key ,
647- class _Cp ,
648- class _Hash ,
649- class _Pred ,
650- bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
651- class __unordered_map_hasher : private _Hash {
652- public:
653- _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher () _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value) : _Hash() {}
654- _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher (const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
655- : _Hash(__h) {}
656- _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function () const _NOEXCEPT { return *this ; }
657- _LIBCPP_HIDE_FROM_ABI size_t operator ()(const _Cp& __x) const { return static_cast <const _Hash&>(*this )(__x.first ); }
658- _LIBCPP_HIDE_FROM_ABI size_t operator ()(const _Key& __x) const { return static_cast <const _Hash&>(*this )(__x); }
659- # if _LIBCPP_STD_VER >= 20
660- template <typename _K2>
661- _LIBCPP_HIDE_FROM_ABI size_t operator ()(const _K2& __x) const {
662- return static_cast <const _Hash&>(*this )(__x);
663- }
664- # endif
665- _LIBCPP_HIDE_FROM_ABI void swap (__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {
666- using std::swap;
667- swap (static_cast <_Hash&>(*this ), static_cast <_Hash&>(__y));
668- }
669- };
670-
671647template <class _Key , class _Cp , class _Hash , class _Pred >
672- class __unordered_map_hasher <_Key, _Cp, _Hash, _Pred, false > {
673- _Hash __hash_;
648+ class __unordered_map_hasher {
649+ _LIBCPP_COMPRESSED_ELEMENT ( _Hash, __hash_) ;
674650
675651public:
676652 _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher () _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
@@ -692,60 +668,16 @@ public:
692668 }
693669};
694670
695- template <class _Key , class _Cp , class _Hash , class _Pred , bool __b >
671+ template <class _Key , class _Cp , class _Hash , class _Pred >
696672inline _LIBCPP_HIDE_FROM_ABI void
697- swap (__unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b >& __x,
698- __unordered_map_hasher<_Key, _Cp, _Hash, _Pred, __b>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
673+ swap (__unordered_map_hasher<_Key, _Cp, _Hash, _Pred>& __x, __unordered_map_hasher<_Key, _Cp, _Hash, _Pred>& __y)
674+ _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
699675 __x.swap (__y);
700676}
701677
702- template <class _Key ,
703- class _Cp ,
704- class _Pred ,
705- class _Hash ,
706- bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
707- class __unordered_map_equal : private _Pred {
708- public:
709- _LIBCPP_HIDE_FROM_ABI __unordered_map_equal () _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value) : _Pred() {}
710- _LIBCPP_HIDE_FROM_ABI __unordered_map_equal (const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
711- : _Pred(__p) {}
712- _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq () const _NOEXCEPT { return *this ; }
713- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _Cp& __x, const _Cp& __y) const {
714- return static_cast <const _Pred&>(*this )(__x.first , __y.first );
715- }
716- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _Cp& __x, const _Key& __y) const {
717- return static_cast <const _Pred&>(*this )(__x.first , __y);
718- }
719- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _Key& __x, const _Cp& __y) const {
720- return static_cast <const _Pred&>(*this )(__x, __y.__get_value ().first );
721- }
722- # if _LIBCPP_STD_VER >= 20
723- template <typename _K2>
724- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _Cp& __x, const _K2& __y) const {
725- return static_cast <const _Pred&>(*this )(__x.first , __y);
726- }
727- template <typename _K2>
728- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _K2& __x, const _Cp& __y) const {
729- return static_cast <const _Pred&>(*this )(__x, __y.__get_value ().first );
730- }
731- template <typename _K2>
732- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _Key& __x, const _K2& __y) const {
733- return static_cast <const _Pred&>(*this )(__x, __y);
734- }
735- template <typename _K2>
736- _LIBCPP_HIDE_FROM_ABI bool operator ()(const _K2& __x, const _Key& __y) const {
737- return static_cast <const _Pred&>(*this )(__x, __y);
738- }
739- # endif
740- _LIBCPP_HIDE_FROM_ABI void swap (__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {
741- using std::swap;
742- swap (static_cast <_Pred&>(*this ), static_cast <_Pred&>(__y));
743- }
744- };
745-
746678template <class _Key , class _Cp , class _Pred , class _Hash >
747- class __unordered_map_equal <_Key, _Cp, _Pred, _Hash, false > {
748- _Pred __pred_;
679+ class __unordered_map_equal {
680+ _LIBCPP_COMPRESSED_ELEMENT ( _Pred, __pred_) ;
749681
750682public:
751683 _LIBCPP_HIDE_FROM_ABI __unordered_map_equal () _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
@@ -780,9 +712,9 @@ public:
780712 }
781713};
782714
783- template <class _Key , class _Cp , class _Pred , class _Hash , bool __b >
715+ template <class _Key , class _Cp , class _Pred , class _Hash >
784716inline _LIBCPP_HIDE_FROM_ABI void
785- swap (__unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b >& __x, __unordered_map_equal<_Key, _Cp, _Pred, _Hash, __b >& __y)
717+ swap (__unordered_map_equal<_Key, _Cp, _Pred, _Hash>& __x, __unordered_map_equal<_Key, _Cp, _Pred, _Hash>& __y)
786718 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
787719 __x.swap (__y);
788720}
0 commit comments