Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / sequences / deque / iterators.pass.cpp
blob484a2961fdb0c9eaefcbac7c3a9bc189838145e5
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 // <deque>
11 // Test nested types and default template args:
13 // template <class T, class Allocator = allocator<T> >
14 // class deque;
16 // iterator, const_iterator
18 #include <deque>
19 #include <iterator>
20 #include <cassert>
22 #include "test_macros.h"
23 #include "min_allocator.h"
25 int main(int, char**)
28 typedef std::deque<int> C;
29 C c;
30 C::iterator i;
31 i = c.begin();
32 C::const_iterator j;
33 j = c.cbegin();
34 assert(i == j);
36 #if TEST_STD_VER >= 11
38 typedef std::deque<int, min_allocator<int>> C;
39 C c;
40 C::iterator i;
41 i = c.begin();
42 C::const_iterator j;
43 j = c.cbegin();
45 assert(i == j);
46 assert(!(i != j));
48 assert(!(i < j));
49 assert((i <= j));
51 assert(!(i > j));
52 assert((i >= j));
54 # if TEST_STD_VER >= 20
55 // P1614 + LWG3352
56 // When the allocator does not have operator<=> then the iterator uses a
57 // fallback to provide operator<=>.
58 // Make sure to test with an allocator that does not have operator<=>.
59 static_assert(!std::three_way_comparable<min_allocator<int>, std::strong_ordering>);
60 static_assert(std::three_way_comparable<typename C::iterator, std::strong_ordering>);
62 std::same_as<std::strong_ordering> decltype(auto) r1 = i <=> j;
63 assert(r1 == std::strong_ordering::equal);
64 # endif
66 #endif
67 #if TEST_STD_VER > 11
68 { // N3644 testing
69 std::deque<int>::iterator ii1{}, ii2{};
70 std::deque<int>::iterator ii4 = ii1;
71 std::deque<int>::const_iterator cii{};
72 assert ( ii1 == ii2 );
73 assert ( ii1 == ii4 );
75 assert (!(ii1 != ii2 ));
77 assert ( (ii1 == cii ));
78 assert ( (cii == ii1 ));
79 assert (!(ii1 != cii ));
80 assert (!(cii != ii1 ));
81 assert (!(ii1 < cii ));
82 assert (!(cii < ii1 ));
83 assert ( (ii1 <= cii ));
84 assert ( (cii <= ii1 ));
85 assert (!(ii1 > cii ));
86 assert (!(cii > ii1 ));
87 assert ( (ii1 >= cii ));
88 assert ( (cii >= ii1 ));
89 assert (cii - ii1 == 0);
90 assert (ii1 - cii == 0);
92 // std::deque<int> c;
93 // assert ( ii1 != c.cbegin());
94 // assert ( cii != c.begin());
95 // assert ( cii != c.cend());
96 // assert ( ii1 != c.end());
98 # if TEST_STD_VER >= 20
99 // P1614 + LWG3352
100 std::same_as<std::strong_ordering> decltype(auto) r1 = ii1 <=> ii2;
101 assert(r1 == std::strong_ordering::equal);
103 std::same_as<std::strong_ordering> decltype(auto) r2 = cii <=> ii2;
104 assert(r2 == std::strong_ordering::equal);
105 # endif // TEST_STD_VER > 20
107 #endif
109 return 0;