[X86] combinePTESTCC - fold PTESTC(PCMPEQ(X,0),-1) == PTESTZ(X,X) (#123466)
[llvm-project.git] / libcxx / test / std / containers / sequences / vector.bool / reference / operator_bool.pass.cpp
blob02abd0e6be766b6d988fcfa653649ab40485959a
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 // <vector>
11 // operator bool()
13 #include <cassert>
14 #include <type_traits>
15 #include <vector>
17 #include "test_macros.h"
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, "");
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);
33 return true;
36 int main(int, char**) {
37 test();
38 #if TEST_STD_VER > 17
39 static_assert(test());
40 #endif
42 return 0;