summaryrefslogtreecommitdiff
path: root/absl/container
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container')
-rw-r--r--absl/container/CMakeLists.txt17
-rw-r--r--absl/container/fixed_array.h2
-rw-r--r--absl/container/inlined_vector.h2
-rw-r--r--absl/container/inlined_vector_test.cc12
-rw-r--r--absl/container/internal/hash_policy_testing.h2
-rw-r--r--absl/container/internal/raw_hash_set.h4
6 files changed, 27 insertions, 12 deletions
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt
index 4d2e1554..72113e19 100644
--- a/absl/container/CMakeLists.txt
+++ b/absl/container/CMakeLists.txt
@@ -48,14 +48,15 @@ list(APPEND CONTAINER_INTERNAL_HEADERS
)
-absl_header_library(
+absl_library(
TARGET
absl_container
+ SOURCES
+ "internal/raw_hash_set.cc"
EXPORT_NAME
container
)
-
#
## TESTS
#
@@ -162,3 +163,15 @@ absl_test(
PUBLIC_LIBRARIES
${TEST_INSTANCE_TRACKER_TEST_PUBLIC_LIBRARIES}
)
+
+absl_test(
+ TARGET
+ raw_hash_set_test
+ SOURCES
+ "internal/raw_hash_set_test.cc"
+ PUBLIC_LIBRARIES
+ absl::base
+ absl::hash
+ absl_internal_throw_delegate
+ test_instance_tracker_lib
+)
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h
index fe67dcee..6da84411 100644
--- a/absl/container/fixed_array.h
+++ b/absl/container/fixed_array.h
@@ -188,7 +188,7 @@ class FixedArray {
// `FixedArray<T>`. This is equivalent to the most possible addressable bytes
// over the number of bytes taken by T.
constexpr size_type max_size() const {
- return std::numeric_limits<difference_type>::max() / sizeof(value_type);
+ return (std::numeric_limits<difference_type>::max)() / sizeof(value_type);
}
// FixedArray::empty()
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 12756bb8..0d773e5a 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -264,7 +264,7 @@ class InlinedVector {
// One bit of the size storage is used to indicate whether the inlined
// vector is allocated; as a result, the maximum size of the container that
// we can express is half of the max for our size type.
- return std::numeric_limits<size_type>::max() / 2;
+ return (std::numeric_limits<size_type>::max)() / 2;
}
// InlinedVector::data()
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc
index 08dcd3ef..5485f454 100644
--- a/absl/container/inlined_vector_test.cc
+++ b/absl/container/inlined_vector_test.cc
@@ -906,6 +906,8 @@ TYPED_TEST_P(InstanceTest, Swap) {
InstanceTracker tracker;
InstanceVec a, b;
const size_t inlined_capacity = a.capacity();
+ auto min_len = std::min(l1, l2);
+ auto max_len = std::max(l1, l2);
for (int i = 0; i < l1; i++) a.push_back(Instance(i));
for (int i = 0; i < l2; i++) b.push_back(Instance(100+i));
EXPECT_EQ(tracker.instances(), l1 + l2);
@@ -919,15 +921,15 @@ TYPED_TEST_P(InstanceTest, Swap) {
EXPECT_EQ(tracker.swaps(), 0); // Allocations are swapped.
EXPECT_EQ(tracker.moves(), 0);
} else if (a.size() <= inlined_capacity && b.size() <= inlined_capacity) {
- EXPECT_EQ(tracker.swaps(), std::min(l1, l2));
- // TODO(bsamwel): This should use moves when the type is movable.
- EXPECT_EQ(tracker.copies(), std::max(l1, l2) - std::min(l1, l2));
+ EXPECT_EQ(tracker.swaps(), min_len);
+ EXPECT_EQ((tracker.moves() ? tracker.moves() : tracker.copies()),
+ max_len - min_len);
} else {
// One is allocated and the other isn't. The allocation is transferred
// without copying elements, and the inlined instances are copied/moved.
EXPECT_EQ(tracker.swaps(), 0);
- // TODO(bsamwel): This should use moves when the type is movable.
- EXPECT_EQ(tracker.copies(), std::min(l1, l2));
+ EXPECT_EQ((tracker.moves() ? tracker.moves() : tracker.copies()),
+ min_len);
}
EXPECT_EQ(l1, b.size());
diff --git a/absl/container/internal/hash_policy_testing.h b/absl/container/internal/hash_policy_testing.h
index ffc76ead..38bbec77 100644
--- a/absl/container/internal/hash_policy_testing.h
+++ b/absl/container/internal/hash_policy_testing.h
@@ -139,7 +139,7 @@ struct Alloc : std::allocator<T> {
friend bool operator!=(const Alloc& a, const Alloc& b) { return !(a == b); }
private:
- size_t id_ = std::numeric_limits<size_t>::max();
+ size_t id_ = (std::numeric_limits<size_t>::max)();
};
template <class Map>
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index 40bdb71b..aa423b25 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -477,7 +477,7 @@ inline size_t NormalizeCapacity(size_t n) {
constexpr size_t kMinCapacity = Group::kWidth - 1;
return n <= kMinCapacity
? kMinCapacity
- : std::numeric_limits<size_t>::max() >> LeadingZeros(n);
+ : (std::numeric_limits<size_t>::max)() >> LeadingZeros(n);
}
// The node_handle concept from C++17.
@@ -1022,7 +1022,7 @@ class raw_hash_set {
bool empty() const { return !size(); }
size_t size() const { return size_; }
size_t capacity() const { return capacity_; }
- size_t max_size() const { return std::numeric_limits<size_t>::max(); }
+ size_t max_size() const { return (std::numeric_limits<size_t>::max)(); }
void clear() {
// Iterating over this container is O(bucket_count()). When bucket_count()