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 // operator bool()
12 
13 #include <cassert>
14 #include <type_traits>
15 #include <vector>
16 
17 #include "test_macros.h"
18 
test()19 TEST_CONSTEXPR_CXX20 bool test() {
20   std::vector<bool> vec;
21   typedef std::vector<bool>::reference Ref;
22   static_assert(std::is_convertible<Ref, bool>::value, "");
23 
24   vec.push_back(true);
25   vec.push_back(false);
26   Ref true_ref = vec[0];
27   Ref false_ref = vec[1];
28   bool b = true_ref;
29   assert(b);
30   assert(true_ref);
31   assert(!false_ref);
32 
33   return true;
34 }
35 
main(int,char **)36 int main(int, char**) {
37   test();
38 #if TEST_STD_VER > 17
39     static_assert(test());
40 #endif
41 
42   return 0;
43 }
44