[PATCH] D41666: Add a value_type to ArrayRef.
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 16 00:38:06 PST 2018
courbet updated this revision to Diff 129922.
courbet added a comment.
Add unit test.
https://reviews.llvm.org/D41666
Files:
include/llvm/ADT/ArrayRef.h
unittests/ADT/ArrayRefTest.cpp
Index: unittests/ADT/ArrayRefTest.cpp
===================================================================
--- unittests/ADT/ArrayRefTest.cpp
+++ unittests/ADT/ArrayRefTest.cpp
@@ -52,6 +52,14 @@
"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) {
Index: include/llvm/ADT/ArrayRef.h
===================================================================
--- include/llvm/ADT/ArrayRef.h
+++ include/llvm/ADT/ArrayRef.h
@@ -45,6 +45,7 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41666.129922.patch
Type: text/x-patch
Size: 983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180116/0ae10746/attachment.bin>
More information about the llvm-commits
mailing list