Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / strings / basic.string / string.iterators / iterators.pass.cpp
blobf44ca0b88835e1aeeaff37a53f552a2a33e0a0aa
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
11 // <string>
13 // iterator begin(); // constexpr since C++20
14 // iterator end(); // constexpr since C++20
15 // const_iterator begin() const; // constexpr since C++20
16 // const_iterator end() const; // constexpr since C++20
17 // const_iterator cbegin() const; // constexpr since C++20
18 // const_iterator cend() const; // constexpr since C++20
20 #include <string>
21 #include <cassert>
23 #include "test_macros.h"
25 template <class C>
26 TEST_CONSTEXPR_CXX20 void test() {
27 { // N3644 testing
28 typename C::iterator ii1{}, ii2{};
29 typename C::iterator ii4 = ii1;
30 typename C::const_iterator cii{};
32 assert(ii1 == ii2);
33 assert(ii1 == ii4);
35 assert(!(ii1 != ii2));
37 assert((ii1 == cii));
38 assert((cii == ii1));
39 assert(!(ii1 != cii));
40 assert(!(cii != ii1));
41 assert(!(ii1 < cii));
42 assert(!(cii < ii1));
43 assert((ii1 <= cii));
44 assert((cii <= ii1));
45 assert(!(ii1 > cii));
46 assert(!(cii > ii1));
47 assert((ii1 >= cii));
48 assert((cii >= ii1));
49 assert(cii - ii1 == 0);
50 assert(ii1 - cii == 0);
53 C a;
54 typename C::iterator i1 = a.begin();
55 typename C::iterator i2;
56 i2 = i1;
57 assert(i1 == i2);
61 TEST_CONSTEXPR_CXX20 bool test() {
62 test<std::string>();
63 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
64 test<std::wstring>();
65 #endif
67 #ifndef TEST_HAS_NO_CHAR8_T
68 test<std::u8string>();
69 #endif
71 test<std::u16string>();
72 test<std::u32string>();
74 return true;
77 int main(int, char**) {
78 test();
79 #if TEST_STD_VER > 17
80 static_assert(test());
81 #endif
82 return 0;