Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / iterators / iterator.primitives / range.iter.ops / range.iter.ops.prev / iterator.pass.cpp
bloba29f7c9555235a16c4658ed58ed11ac54f20e79a
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // ranges::prev(it)
13 #include <iterator>
14 #include <cassert>
16 #include "test_iterators.h"
18 template <class It>
19 constexpr void check(int* first, int* expected) {
20 It it(first);
21 std::same_as<It> auto result = std::ranges::prev(std::move(it));
22 assert(base(result) == expected);
25 constexpr bool test() {
26 int range[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
28 for (int n = 1; n != 10; ++n) {
29 check<bidirectional_iterator<int*>>(range+n, range+n-1);
30 check<random_access_iterator<int*>>(range+n, range+n-1);
31 check<contiguous_iterator<int*>>( range+n, range+n-1);
32 check<int*>( range+n, range+n-1);
35 return true;
39 int main(int, char**) {
40 test();
41 static_assert(test());
42 return 0;