vector<bool>::reference Class

The vector<bool>::reference class is a proxy class to the vector<bool> Class whose objects are able to provide reference simulation to elements (single bits) within a vector<bool> object.

Remarks

A simulated reference is needed because C++ does not natively allow direct reference to bits. vector<bool> uses only one bit per element, and these can be referenced using the objects in this proxy class. The reference simulation is not complete, as certain assignments are not valid. For example, you cannot take the address of the vector<bool>::reference object, so the following code that uses vector<bool>::operator[] is not correct:

    vector<bool> v;
...
    bool* pvb = &v[1]; // conversion error - do not use
    bool& vb = v[1];   // conversion error - do not use

Member Functions

flip

Inverts the Boolean value of a vector element.

operator bool

Exchanges the elements of two vectors with Boolean elements.

operator=

Assigns a Boolean value to a bit or the value held by a referenced element to a bit.

Requirements

Header: <vector>

Namespace: std

See Also

Reference

<vector>

Thread Safety in the Standard C++ Library

Standard Template Library