60
60
#include < cstring>
61
61
#include < limits>
62
62
#include < new>
63
+ #include < type_traits>
63
64
64
65
#include " phmap_fwd_decl.h"
65
66
#include " phmap_base.h"
76
77
77
78
namespace phmap {
78
79
79
- // Defined and documented later on in this file.
80
- template <typename T>
81
- struct is_trivially_destructible ;
82
-
83
- // Defined and documented later on in this file.
84
- template <typename T>
85
- struct is_trivially_move_assignable ;
86
-
87
80
namespace type_traits_internal {
88
81
89
82
// Silence MSVC warnings about the destructor being defined as deleted.
@@ -107,26 +100,26 @@ namespace phmap {
107
100
: std::integral_constant<
108
101
bool , std::is_move_constructible<
109
102
type_traits_internal::SingleMemberUnion<T>>::value &&
110
- phmap ::is_trivially_destructible<T>::value> {};
103
+ std ::is_trivially_destructible<T>::value> {};
111
104
112
105
template <class T >
113
106
struct IsTriviallyCopyConstructibleObject
114
107
: std::integral_constant<
115
108
bool , std::is_copy_constructible<
116
109
type_traits_internal::SingleMemberUnion<T>>::value &&
117
- phmap ::is_trivially_destructible<T>::value> {};
118
-
110
+ std ::is_trivially_destructible<T>::value> {};
111
+ # if 0
119
112
template <class T>
120
113
struct IsTriviallyMoveAssignableReference : std::false_type {};
121
114
122
115
template <class T>
123
116
struct IsTriviallyMoveAssignableReference<T&>
124
- : phmap ::is_trivially_move_assignable<T>::type {};
117
+ : std ::is_trivially_move_assignable<T>::type {};
125
118
126
119
template <class T>
127
120
struct IsTriviallyMoveAssignableReference<T&&>
128
- : phmap ::is_trivially_move_assignable<T>::type {};
129
-
121
+ : std ::is_trivially_move_assignable<T>::type {};
122
+ # endif
130
123
} // namespace type_traits_internal
131
124
132
125
@@ -155,10 +148,10 @@ namespace phmap {
155
148
156
149
public:
157
150
static constexpr bool kValue =
158
- (__has_trivial_copy( ExtentsRemoved) || !kIsCopyOrMoveConstructible ) &&
159
- (__has_trivial_assign( ExtentsRemoved) || !kIsCopyOrMoveAssignable ) &&
151
+ (phmap::is_trivially_copyable< ExtentsRemoved>::value || !kIsCopyOrMoveConstructible ) &&
152
+ (phmap::is_trivially_copy_assignable< ExtentsRemoved>::value || !kIsCopyOrMoveAssignable ) &&
160
153
(kIsCopyOrMoveConstructible || kIsCopyOrMoveAssignable ) &&
161
- is_trivially_destructible<ExtentsRemoved>::value &&
154
+ std:: is_trivially_destructible<ExtentsRemoved>::value &&
162
155
// We need to check for this explicitly because otherwise we'll say
163
156
// references are trivial copyable when compiled by MSVC.
164
157
!std::is_reference<ExtentsRemoved>::value;
@@ -744,13 +737,13 @@ namespace priv {
744
737
StringBtreeDefaultLess (std::less<std::string_view>) {} // NOLINT
745
738
StringBtreeDefaultLess (phmap::Less<std::string_view>) {} // NOLINT
746
739
747
- phmap::weak_ordering operator ()(std::string_view lhs,
748
- std::string_view rhs) const {
740
+ phmap::weak_ordering operator ()(const std::string_view & lhs,
741
+ const std::string_view & rhs) const {
749
742
return compare_internal::compare_result_as_ordering (lhs.compare (rhs));
750
743
}
751
744
#else
752
- phmap::weak_ordering operator ()(std::string lhs,
753
- std::string rhs) const {
745
+ phmap::weak_ordering operator ()(const std::string & lhs,
746
+ const std::string & rhs) const {
754
747
return compare_internal::compare_result_as_ordering (lhs.compare (rhs));
755
748
}
756
749
#endif
@@ -770,8 +763,8 @@ namespace priv {
770
763
return compare_internal::compare_result_as_ordering (rhs.compare (lhs));
771
764
}
772
765
#else
773
- phmap::weak_ordering operator ()(std::string lhs,
774
- std::string rhs) const {
766
+ phmap::weak_ordering operator ()(const std::string & lhs,
767
+ const std::string & rhs) const {
775
768
return compare_internal::compare_result_as_ordering (rhs.compare (lhs));
776
769
}
777
770
#endif
@@ -1868,7 +1861,7 @@ namespace priv {
1868
1861
void swap (btree &x);
1869
1862
1870
1863
const key_compare &key_comp () const noexcept {
1871
- return root_. template get <0 >();
1864
+ return std:: get<0 >(root_ );
1872
1865
}
1873
1866
template <typename K, typename LK>
1874
1867
bool compare_keys (const K &x, const LK &y) const {
@@ -1961,21 +1954,21 @@ namespace priv {
1961
1954
1962
1955
private:
1963
1956
// Internal accessor routines.
1964
- node_type *root () { return root_. template get <2 >(); }
1965
- const node_type *root () const { return root_. template get <2 >(); }
1966
- node_type *&mutable_root () noexcept { return root_. template get <2 >(); }
1967
- key_compare *mutable_key_comp () noexcept { return &root_. template get <0 >(); }
1957
+ node_type *root () { return std:: get<2 >(root_ ); }
1958
+ const node_type *root () const { return std:: get<2 >(root_ ); }
1959
+ node_type *&mutable_root () noexcept { return std:: get<2 >(root_ ); }
1960
+ key_compare *mutable_key_comp () noexcept { return &std:: get<0 >(root_ ); }
1968
1961
1969
1962
// The leftmost node is stored as the parent of the root node.
1970
1963
node_type *leftmost () { return root ()->parent (); }
1971
1964
const node_type *leftmost () const { return root ()->parent (); }
1972
1965
1973
1966
// Allocator routines.
1974
1967
allocator_type *mutable_allocator () noexcept {
1975
- return &root_. template get <1 >();
1968
+ return &std:: get<1 >(root_ );
1976
1969
}
1977
1970
const allocator_type &allocator () const noexcept {
1978
- return root_. template get <1 >();
1971
+ return std:: get<1 >(root_ );
1979
1972
}
1980
1973
1981
1974
// Allocates a correctly aligned node of at least size bytes using the
@@ -2117,11 +2110,7 @@ namespace priv {
2117
2110
}
2118
2111
2119
2112
private:
2120
- // We use compressed tuple in order to save space because key_compare and
2121
- // allocator_type are usually empty.
2122
- phmap::priv::CompressedTuple<key_compare, allocator_type,
2123
- node_type *>
2124
- root_;
2113
+ std::tuple<key_compare, allocator_type, node_type *> root_;
2125
2114
2126
2115
// A pointer to the rightmost node. Note that the leftmost node is stored as
2127
2116
// the root's parent.
@@ -3332,8 +3321,8 @@ namespace priv {
3332
3321
// ----------------
3333
3322
template <typename K = key_type>
3334
3323
size_type count (const key_arg<K> &key) const {
3335
- auto equal_range = this ->equal_range (key);
3336
- return std::distance (equal_range .first , equal_range .second );
3324
+ auto er = this ->equal_range (key);
3325
+ return std::distance (er .first , er .second );
3337
3326
}
3338
3327
template <typename K = key_type>
3339
3328
iterator find (const key_arg<K> &key) {
@@ -3373,8 +3362,8 @@ namespace priv {
3373
3362
}
3374
3363
template <typename K = key_type>
3375
3364
size_type erase (const key_arg<K> &key) {
3376
- auto equal_range = this ->equal_range (key);
3377
- return tree_.erase_range (equal_range .first , equal_range .second ).first ;
3365
+ auto er = this ->equal_range (key);
3366
+ return tree_.erase_range (er .first , er .second ).first ;
3378
3367
}
3379
3368
node_type extract (iterator position) {
3380
3369
// Use Move instead of Transfer, because the rebalancing code expects to
0 commit comments