vector < bool > is a special special template specification for the bool type.
This specialization is provided to optimize the distribution of space: eight bool elements are combined into one byte, and each bool element occupies only one bit.
Reference to one bit in a specific byte is not allowed.
Thus, the function could not return a reference to the bool type in the < bool > vector.
Someone also thinks that vector < bool > is not a container.
You can use deque < bool > instead.
source share