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 // flip() 12 13 #include <cassert> 14 #include <vector> 15 16 bool test() { 17 std::vector<bool> vec; 18 typedef std::vector<bool>::reference Ref; 19 vec.push_back(true); 20 vec.push_back(false); 21 Ref ref = vec[0]; 22 assert(vec[0]); 23 assert(!vec[1]); 24 ref.flip(); 25 assert(!vec[0]); 26 assert(!vec[1]); 27 ref.flip(); 28 assert(vec[0]); 29 assert(!vec[1]); 30 31 return true; 32 } 33 34 int main(int, char**) { 35 test(); 36 37 return 0; 38 } 39