[libcxx-commits] [PATCH] D118279: [libcxx][test] MaybePOCCAAllocator should meet the Cpp17Allocator requirements

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 25 11:04:10 PDT 2022


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 rGc5ba46ea1804: [libcxx][test] MaybePOCCAAllocator should meet the Cpp17Allocator requirements (authored by CaseyCarter).
Herald added a project: All.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118279

Files:
  libcxx/test/support/allocators.h


Index: libcxx/test/support/allocators.h
===================================================================
--- libcxx/test/support/allocators.h
+++ libcxx/test/support/allocators.h
@@ -189,14 +189,26 @@
 class MaybePOCCAAllocator {
     int id_ = 0;
     bool* copy_assigned_into_ = nullptr;
+
+    template<class, bool> friend class MaybePOCCAAllocator;
+
 public:
     typedef std::integral_constant<bool, POCCAValue> propagate_on_container_copy_assignment;
     typedef T value_type;
 
+    template <class U>
+    struct rebind {
+        typedef MaybePOCCAAllocator<U, POCCAValue> other;
+    };
+
     MaybePOCCAAllocator() = default;
     MaybePOCCAAllocator(int id, bool* copy_assigned_into)
         : id_(id), copy_assigned_into_(copy_assigned_into) {}
 
+    template <class U>
+    MaybePOCCAAllocator(const MaybePOCCAAllocator<U, POCCAValue>& that)
+        : id_(that.id_), copy_assigned_into_(that.copy_assigned_into_) {}
+
     MaybePOCCAAllocator(const MaybePOCCAAllocator&) = default;
     MaybePOCCAAllocator& operator=(const MaybePOCCAAllocator& a)
     {
@@ -218,12 +230,14 @@
 
     int id() const { return id_; }
 
-    friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs)
+    template <class U>
+    friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
     {
         return lhs.id() == rhs.id();
     }
 
-    friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator& rhs)
+    template <class U>
+    friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
     {
         return !(lhs == rhs);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118279.439999.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220625/aa814557/attachment.bin>


More information about the libcxx-commits mailing list