[llvm] r351954 - Re-land rL322538 "Add a value_type to ArrayRef."
Clement Courbet via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 23 06:20:59 PST 2019
Author: courbet
Date: Wed Jan 23 06:20:59 2019
New Revision: 351954
URL: http://llvm.org/viewvc/llvm-project?rev=351954&view=rev
Log:
Re-land rL322538 "Add a value_type to ArrayRef."
Modified:
llvm/trunk/include/llvm/ADT/ArrayRef.h
llvm/trunk/unittests/ADT/ArrayRefTest.cpp
Modified: llvm/trunk/include/llvm/ADT/ArrayRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ArrayRef.h?rev=351954&r1=351953&r2=351954&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ArrayRef.h (original)
+++ llvm/trunk/include/llvm/ADT/ArrayRef.h Wed Jan 23 06:20:59 2019
@@ -44,6 +44,7 @@ namespace llvm {
using const_iterator = const T *;
using size_type = size_t;
using reverse_iterator = std::reverse_iterator<iterator>;
+ using value_type = typename std::remove_cv<T>::type;
private:
/// The start of the array, in an external buffer.
Modified: llvm/trunk/unittests/ADT/ArrayRefTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=351954&r1=351953&r2=351954&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/ArrayRefTest.cpp (original)
+++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp Wed Jan 23 06:20:59 2019
@@ -51,6 +51,14 @@ static_assert(
"Assigning from an initializer list");
#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 {
TEST(ArrayRefTest, AllocatorCopy) {
More information about the llvm-commits
mailing list