Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::vector::flip(3)	      C++ Standard Libary	  std::vector::flip(3)

NAME
       std::vector::flip - std::vector::flip

Synopsis
	  Defined in header <vector>
	  void flip();		      (until C++20)
	  constexpr void flip();      (since C++20)

	  Toggles each bool in the vector (replaces with its opposite value).

Parameters
	  (none)

Return value
	  (none)

Example
       // Run this code

	#include <iostream>
	#include <vector>

	void print(const std::vector<bool>& vb)	{
	    for	(const bool b :	vb)
		std::cout << b;
	    std::cout << '\n';
	}

	int main() {
	    std::vector<bool> v{0, 1, 0, 1};
	    print(v);
	    v.flip();
	    print(v);
	}

Output:
	0101
	1010

See also
	  operator[] access specified element
		     (public member function of	std::vector<T,Allocator>)
	  flip	     toggles the values	of bits
		     (public member function of	std::bitset<N>)

http://cppreference.com		  2022.07.31		  std::vector::flip(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::vector::flip&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help