[llvm] 9909237 - [ADT][NFC] Add extra typedefs to `ArrayRef` and `MutableArrayRef`
Vladislav Vinogradov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 07:36:59 PST 2021
Author: Vladislav Vinogradov
Date: 2021-02-26T18:37:08+03:00
New Revision: 9909237d992000d651b32212d15111453485a6b0
URL: https://github.com/llvm/llvm-project/commit/9909237d992000d651b32212d15111453485a6b0
DIFF: https://github.com/llvm/llvm-project/commit/9909237d992000d651b32212d15111453485a6b0.diff
LOG: [ADT][NFC] Add extra typedefs to `ArrayRef` and `MutableArrayRef`
* `value_type`
* `pointer`
* `const_pointer`
* `reference`
* `const_reference`
* `const_reverse_iterator`
* `size_type`
* `difference_type`
It makes `ArrayRef` and `MutableArrayRef` types fully compliant with STL Container concept.
Reviewed By: lattner, courbet
Differential Revision: https://reviews.llvm.org/D95611
Added:
Modified:
llvm/include/llvm/ADT/ArrayRef.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 5ed4d0766c34..bc656109c221 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -40,10 +40,17 @@ namespace llvm {
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 = T;
+ using pointer = value_type *;
+ using const_pointer = const value_type *;
+ using reference = value_type &;
+ using const_reference = const value_type &;
+ using iterator = const_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 = size_t;
+ using
diff erence_type = ptr
diff _t;
private:
/// The start of the array, in an external buffer.
@@ -297,8 +304,17 @@ namespace llvm {
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 = size_t;
+ using
diff erence_type = ptr
diff _t;
/// Construct an empty MutableArrayRef.
/*implicit*/ MutableArrayRef() = default;
More information about the llvm-commits
mailing list