vector - STL C++

vector<bool, A>::flip()

Declaration

vector<bool, A>::flip();

Description

This the flip() function for the vector class template specialization of the bool type, which flips the each of the bits. This is the vector equivalent to a bitwise not operation.

Header Include

#include <vector>

Example

#include <iostream>
#include <vector>

int main()
{
	using namespace std;

	// Create a default vector and add bits to it
	vector<bool> qBitVector;
	qBitVector.push_back(true);
	qBitVector.push_back(false);
	qBitVector.push_back(false);
	qBitVector.push_back(true);
	qBitVector.push_back(true);

	// Output the vector and the flipped version
	for (int i = 0; i < 2; ++i) {
		(i == 0) ? cout << "Vector  = " : cout << "Flipped = ";
		vector<bool>::iterator qIter;
		for (qIter = qBitVector.begin(); qIter != qBitVector.end(); ++qIter) {
			cout << *qIter;
		}
		cout << endl;
		qBitVector.flip();
	}

	cin.get();
	return 0;
}

Output

vector<bool, A>::flip() Output
 

© 2007–2025 XoaX.net LLC. All rights reserved.