Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / reverse.iterators / reverse.iter.nav / plus.pass.cpp
blob24fa84e4f37c8b67dfdfc01fe47b90dd3d16f4f8
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <iterator>
11 // reverse_iterator
13 // requires RandomAccessIterator<Iter>
14 // reverse_iterator operator+(difference_type n) const; // constexpr in C++17
16 #include <iterator>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "test_iterators.h"
22 template <class It>
23 TEST_CONSTEXPR_CXX17 void test(It i, typename std::iterator_traits<It>::difference_type n, It x) {
24 const std::reverse_iterator<It> r(i);
25 std::reverse_iterator<It> rr = r + n;
26 assert(rr.base() == x);
29 TEST_CONSTEXPR_CXX17 bool tests() {
30 const char* s = "1234567890";
31 test(random_access_iterator<const char*>(s + 5), 5, random_access_iterator<const char*>(s));
32 #if TEST_STD_VER >= 20
33 test(cpp20_random_access_iterator<const char*>(s + 5), 5, cpp20_random_access_iterator<const char*>(s));
34 #endif
35 test(s+5, 5, s);
36 return true;
39 int main(int, char**) {
40 tests();
41 #if TEST_STD_VER > 14
42 static_assert(tests(), "");
43 #endif
44 return 0;