Ver código fonte

Add a value_type to ArrayRef.

Summary: Not sure this needs a review or not. Erring on the safe side.

Reviewers: dblaikie

Differential Revision: https://reviews.llvm.org/D41666

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322538 91177308-0d34-0410-b5e6-96231b3b80d8
Clement Courbet 7 anos atrás
pai
commit
262e25ddf8
2 arquivos alterados com 9 adições e 0 exclusões
  1. 1 0
      include/llvm/ADT/ArrayRef.h
  2. 8 0
      unittests/ADT/ArrayRefTest.cpp

+ 1 - 0
include/llvm/ADT/ArrayRef.h

@@ -45,6 +45,7 @@ namespace llvm {
     using const_iterator = const T *;
     using const_iterator = const T *;
     using size_type = size_t;
     using size_type = size_t;
     using reverse_iterator = std::reverse_iterator<iterator>;
     using reverse_iterator = std::reverse_iterator<iterator>;
+    using value_type = typename std::remove_cv<T>::type;
 
 
   private:
   private:
     /// The start of the array, in an external buffer.
     /// The start of the array, in an external buffer.

+ 8 - 0
unittests/ADT/ArrayRefTest.cpp

@@ -52,6 +52,14 @@ static_assert(
     "Assigning from an initializer list");
     "Assigning from an initializer list");
 #endif
 #endif
 
 
+// Check Typedefs.
+static_assert(
+    std::is_same<ArrayRef<int>::value_type, int>::value,
+    "erroneous value_type");
+static_assert(
+    std::is_same<ArrayRef<const int>::value_type, int>::value,
+    "erroneous value_type");
+
 namespace {
 namespace {
 
 
 TEST(ArrayRefTest, AllocatorCopy) {
 TEST(ArrayRefTest, AllocatorCopy) {