[PATCH] D95611: [ADT][NFC] Add extra typedefs to `ArrayRef` and `MutableArrayRef`

Vladislav Vinogradov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 00:30:39 PST 2021


vinograd47 updated this revision to Diff 320406.
vinograd47 added a comment.

Rebased to latest main branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95611

Files:
  llvm/include/llvm/ADT/ArrayRef.h


Index: llvm/include/llvm/ADT/ArrayRef.h
===================================================================
--- llvm/include/llvm/ADT/ArrayRef.h
+++ llvm/include/llvm/ADT/ArrayRef.h
@@ -40,10 +40,17 @@
   template<typename T>
   class LLVM_GSL_POINTER LLVM_NODISCARD ArrayRef {
   public:
-    using iterator = const T *;
-    using const_iterator = const T *;
-    using size_type = size_t;
+    using value_type = const T;
+    using pointer = value_type *;
+    using const_pointer = const value_type *;
+    using reference = value_type &;
+    using const_reference = const value_type &;
+    using iterator = pointer;
+    using const_iterator = const_pointer;
     using reverse_iterator = std::reverse_iterator<iterator>;
+    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+    using size_type = std::size_t;
+    using difference_type = std::ptrdiff_t;
 
   private:
     /// The start of the array, in an external buffer.
@@ -297,8 +304,17 @@
   template<typename T>
   class LLVM_NODISCARD MutableArrayRef : public ArrayRef<T> {
   public:
-    using iterator = T *;
+    using value_type = T;
+    using pointer = value_type *;
+    using const_pointer = const value_type *;
+    using reference = value_type &;
+    using const_reference = const value_type &;
+    using iterator = pointer;
+    using const_iterator = const_pointer;
     using reverse_iterator = std::reverse_iterator<iterator>;
+    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+    using size_type = std::size_t;
+    using difference_type = std::ptrdiff_t;
 
     /// Construct an empty MutableArrayRef.
     /*implicit*/ MutableArrayRef() = default;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95611.320406.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210201/7dcda837/attachment.bin>


More information about the llvm-commits mailing list