about summary refs log tree commit diff
path: root/absl/container
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container')
-rw-r--r--absl/container/BUILD.bazel1
-rw-r--r--absl/container/CMakeLists.txt2
-rw-r--r--absl/container/inlined_vector.h2
-rw-r--r--absl/container/internal/inlined_vector.h8
-rw-r--r--absl/container/internal/test_instance_tracker.h10
-rw-r--r--absl/container/internal/test_instance_tracker_test.cc2
6 files changed, 18 insertions, 7 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel
index f25a9ff96b0b..0488857e7c58 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -213,6 +213,7 @@ cc_library(
     visibility = [
         "//absl:__subpackages__",
     ],
+    deps = ["//absl/types:compare"],
 )
 
 cc_test(
diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt
index 9531d7f92448..1e203dbf1ccc 100644
--- a/absl/container/CMakeLists.txt
+++ b/absl/container/CMakeLists.txt
@@ -204,6 +204,8 @@ absl_cc_library(
     "internal/test_instance_tracker.cc"
   COPTS
     ${ABSL_DEFAULT_COPTS}
+  DEPS
+    absl::compare
   TESTONLY
 )
 
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 34e9aa0a124e..16865272c481 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -69,7 +69,7 @@ class InlinedVector {
   static_assert(
       N > 0, "InlinedVector cannot be instantiated with `0` inlined elements.");
 
-  using Storage = inlined_vector_internal::Storage<InlinedVector>;
+  using Storage = inlined_vector_internal::Storage<T, N, A>;
   using AllocatorTraits = typename Storage::AllocatorTraits;
 
   template <typename Iterator>
diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h
index b8b4f4ce3b39..6a5a75be1f20 100644
--- a/absl/container/internal/inlined_vector.h
+++ b/absl/container/internal/inlined_vector.h
@@ -31,12 +31,8 @@ using IsAtLeastForwardIterator = std::is_convertible<
     typename std::iterator_traits<Iterator>::iterator_category,
     std::forward_iterator_tag>;
 
-template <typename InlinedVector>
-class Storage;
-
-template <template <typename, size_t, typename> class InlinedVector, typename T,
-          size_t N, typename A>
-class Storage<InlinedVector<T, N, A>> {
+template <typename T, size_t N, typename A>
+class Storage {
  public:
   using allocator_type = A;
   using value_type = typename allocator_type::value_type;
diff --git a/absl/container/internal/test_instance_tracker.h b/absl/container/internal/test_instance_tracker.h
index 032d16d33ffa..3d4b2980ea8b 100644
--- a/absl/container/internal/test_instance_tracker.h
+++ b/absl/container/internal/test_instance_tracker.h
@@ -18,6 +18,8 @@
 #include <cstdlib>
 #include <ostream>
 
+#include "absl/types/compare.h"
+
 namespace absl {
 namespace test_internal {
 
@@ -96,6 +98,14 @@ class BaseCountedInstance {
     return value_ >= x.value_;
   }
 
+  absl::weak_ordering compare(const BaseCountedInstance& x) const {
+    ++num_comparisons_;
+    return value_ < x.value_
+               ? absl::weak_ordering::less
+               : value_ == x.value_ ? absl::weak_ordering::equivalent
+                                    : absl::weak_ordering::greater;
+  }
+
   int value() const {
     if (!is_live_) std::abort();
     return value_;
diff --git a/absl/container/internal/test_instance_tracker_test.cc b/absl/container/internal/test_instance_tracker_test.cc
index 091f428da409..1c6a4fa7150d 100644
--- a/absl/container/internal/test_instance_tracker_test.cc
+++ b/absl/container/internal/test_instance_tracker_test.cc
@@ -174,6 +174,8 @@ TEST(TestInstanceTracker, Comparisons) {
   EXPECT_EQ(5, tracker.comparisons());
   EXPECT_FALSE(one >= two);
   EXPECT_EQ(6, tracker.comparisons());
+  EXPECT_TRUE(one.compare(two) < 0);  // NOLINT
+  EXPECT_EQ(7, tracker.comparisons());
 
   tracker.ResetCopiesMovesSwaps();
   EXPECT_EQ(0, tracker.comparisons());