Section

std::vector<bool>

std::vector is a possibly space-efficient specialization of std::vector for the type bool.

# Declarations

template<
class Allocator
> class vector<bool, Allocator>;

# Notes

If the size of the bitset is known at compile time, std::bitset may be used, which offers a richer set of member functions. In addition, boost::dynamic_bitset exists as an alternative to std::vector.

Since its representation may be optimized, std::vector does not necessarily meet all Container or SequenceContainer requirements. For example, because std::vector::iterator is implementation-defined, it may not satisfy the LegacyForwardIterator requirement. Use of algorithms such as std::search that require LegacyForwardIterators may result in either compile-time or run-time errors.

The Boost.Container version of vector does not specialize for bool.

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2187C++11specializations for bool lacked emplace and emplace_back member functionsadded