Skip to content

Commit c795634

Browse files
committed
Re-land rL322538 "Add a value_type to ArrayRef."
llvm-svn: 351954
1 parent 0e08b6f commit c795634

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace llvm {
4444
using const_iterator = const T *;
4545
using size_type = size_t;
4646
using reverse_iterator = std::reverse_iterator<iterator>;
47+
using value_type = typename std::remove_cv<T>::type;
4748

4849
private:
4950
/// The start of the array, in an external buffer.

llvm/unittests/ADT/ArrayRefTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ static_assert(
5151
"Assigning from an initializer list");
5252
#endif
5353

54+
// Check Typedefs.
55+
static_assert(
56+
std::is_same<ArrayRef<int>::value_type, int>::value,
57+
"erroneous value_type");
58+
static_assert(
59+
std::is_same<ArrayRef<const int>::value_type, int>::value,
60+
"erroneous value_type");
61+
5462
namespace {
5563

5664
TEST(ArrayRefTest, AllocatorCopy) {

0 commit comments

Comments
 (0)