Jump to content

C++ Language/Std/Stl/CollectionClasses/SequenceCollections/VectorOfBool

From Wikibooks, open books for an open world

A special specialization std::vector<bool> compresses each item to a single bit.

For this special specialization, the indexing operator doesn't return bool&. Instead, it returns a reference to an auxillary class that defines both vecyVar[iIndex].flip() and a cast-operator for getting and setting its bool value.

Additional information about a vector of bool (includes interactive examples)