xref: /llvm-project/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp (revision 98d3d5b5da66e3cf7807c23a0294280bb796466b)
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 //===----------------------------------------------------------------------===//
8 
9 // <vector>
10 
11 // class vector
12 
13 // bool empty() const noexcept;
14 
15 #include <vector>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 
tests()21 TEST_CONSTEXPR_CXX20 bool tests()
22 {
23     {
24     typedef std::vector<bool> C;
25     C c;
26     ASSERT_NOEXCEPT(c.empty());
27     assert(c.empty());
28     c.push_back(false);
29     assert(!c.empty());
30     c.clear();
31     assert(c.empty());
32     }
33 #if TEST_STD_VER >= 11
34     {
35     typedef std::vector<bool, min_allocator<bool>> C;
36     C c;
37     ASSERT_NOEXCEPT(c.empty());
38     assert(c.empty());
39     c.push_back(false);
40     assert(!c.empty());
41     c.clear();
42     assert(c.empty());
43     }
44 #endif
45 
46     return true;
47 }
48 
main(int,char **)49 int main(int, char**)
50 {
51     tests();
52 #if TEST_STD_VER > 17
53     static_assert(tests());
54 #endif
55     return 0;
56 }
57