[libcxx-commits] [PATCH] D131079: [libcxx][test] fix allocator in allocator_propagation test

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 4 15:34:58 PST 2023


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd65e66abb3bd: [libcxx][test] fix allocator in allocator_propagation test (authored by CaseyCarter).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131079/new/

https://reviews.llvm.org/D131079

Files:
  libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp


Index: libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/allocator_propagation.pass.cpp
@@ -24,10 +24,10 @@
   using value_type = T;
 
   constexpr explicit soccc_allocator(int* soccc_count_, int self_coccc_count_ = 0)
-      : soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
+    : soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
 
   template <class U>
-  constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.soccc_count) {}
+  constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.get_soccc()) {}
 
   constexpr T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
   constexpr void deallocate(T* p, std::size_t s) { std::allocator<T>().deallocate(p, s); }
@@ -37,12 +37,17 @@
     return soccc_allocator(soccc_count, self_soccc_count + 1);
   }
 
-  constexpr auto get_soccc() { return soccc_count; }
-  constexpr auto get_self_soccc() { return self_soccc_count; }
+  constexpr auto get_soccc() const { return soccc_count; }
+  constexpr auto get_self_soccc() const { return self_soccc_count; }
 
   typedef std::true_type propagate_on_container_copy_assignment;
   typedef std::true_type propagate_on_container_move_assignment;
   typedef std::true_type propagate_on_container_swap;
+
+  template <class U>
+  constexpr bool operator==(const soccc_allocator<U>& that) const {
+    return soccc_count == that.get_soccc();
+  }
 };
 
 template <class CharT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131079.486412.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230104/55d1404e/attachment.bin>


More information about the libcxx-commits mailing list