
In the Standard C++ Library, vectors of bit values (boolean 1/0 values) are handled as a special case, so that the values can be efficiently packed with several elements to a word. The operations for a boolean vector, vector<bool>, are a superset of those for an ordinary vector, only the implementation is more efficient.
One new member function added to the boolean vector datatype is flip(). When invoked, this function inverts all the bits of the vector. Boolean vectors also return as reference an internal value that also supports the flip() member function:
std::vector<bool> bvec(27); bvec.flip(); // flip all values bvec[17].flip(); // flip bit 17
The vector<bool> also supports an additional swap() member function that allows swapping the values indicated by a pair of references:
bvec.swap(bvec [17], bvec [16]);
Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).