1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // requires RandomAccessIterator<Iter>
14 // unspecified operator[](difference_type n) const; // constexpr since C++17
19 #include "test_macros.h"
20 #include "test_iterators.h"
23 TEST_CONSTEXPR_CXX17
void test(It i
,
24 typename
std::iterator_traits
<It
>::difference_type n
,
25 typename
std::iterator_traits
<It
>::value_type x
) {
26 typedef typename
std::iterator_traits
<It
>::value_type value_type
;
27 const std::reverse_iterator
<It
> r(i
);
32 TEST_CONSTEXPR_CXX17
bool tests() {
33 const char* s
= "1234567890";
34 test(random_access_iterator
<const char*>(s
+5), 4, '1');
35 test(random_access_iterator
<const char*>(s
+5), 0, '5');
41 int main(int, char**) {
44 static_assert(tests(), "");