]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2020-2023 Free Software Foundation, Inc. |
bd2420f8 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
b9a2dce8 | 18 | // { dg-do compile { target c++20 } } |
bd2420f8 JW |
19 | |
20 | #include <vector> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
1ae8edf5 | 23 | constexpr bool |
bd2420f8 JW |
24 | test01() |
25 | { | |
26 | std::vector<bool> c1{ 1, 0, 1 }, c2{ 1, 0, 1, 0 }, c3{ 1, 1, 1 }; | |
27 | VERIFY( c1 == c1 ); | |
28 | VERIFY( std::is_eq(c1 <=> c1) ); | |
29 | VERIFY( c1 < c2 ); | |
30 | VERIFY( std::is_lt(c1 <=> c2) ); | |
31 | VERIFY( c1 < c3 ); | |
32 | VERIFY( std::is_lt(c1 <=> c3) ); | |
33 | VERIFY( c2 < c3 ); | |
34 | VERIFY( std::is_lt(c2 <=> c3) ); | |
35 | ||
36 | static_assert( std::totally_ordered<std::vector<bool>> ); | |
37 | ||
38 | static_assert( std::three_way_comparable<std::vector<bool>, | |
39 | std::strong_ordering> ); | |
1ae8edf5 JW |
40 | |
41 | return true; | |
bd2420f8 JW |
42 | } |
43 | ||
1ae8edf5 | 44 | constexpr bool |
bd2420f8 JW |
45 | test05() |
46 | { | |
47 | // vector<bool> iterators are random access, so should support <=> | |
48 | ||
49 | std::vector<bool> c{ 1, 1, 1 }; | |
50 | VERIFY( c.begin() == c.cbegin() ); | |
51 | VERIFY( std::is_eq(c.begin() <=> c.cbegin()) ); | |
52 | ||
53 | VERIFY( c.begin() < c.end() ); | |
54 | VERIFY( std::is_lt(c.begin() <=> c.end()) ); | |
55 | ||
56 | VERIFY( c.begin() < c.cend() ); | |
57 | VERIFY( std::is_lt(c.begin() <=> c.cend()) ); | |
58 | ||
59 | VERIFY( c.crbegin() == c.rbegin() ); | |
60 | VERIFY( std::is_eq(c.crbegin() <=> c.rbegin()) ); | |
61 | ||
62 | VERIFY( c.rend() > c.rbegin() ); | |
63 | VERIFY( std::is_gt(c.rend() <=> c.rbegin()) ); | |
64 | ||
65 | static_assert( std::same_as<decltype(c.begin() <=> c.begin()), | |
66 | std::strong_ordering> ); | |
bd2420f8 | 67 | |
1ae8edf5 | 68 | return true; |
bd2420f8 | 69 | } |
1ae8edf5 JW |
70 | |
71 | static_assert( test01() ); | |
72 | static_assert( test05() ); |