17.1 General

17.1.1 Do not use std::vector<bool>

The std::vector<bool> specialization does not conform to the requirements of a container and does not work as expected in all STL algorithms. In particular &v[0] does not return a contiguous array of elements as it does for other vector types. Additionally, the C++ Language Standard guarantees that different elements of an STL container can safely be modified concurrently, except for a container of std::vector<bool> type.

#include <cstdint>
#include <vector>
void foo ()
std::vector <int32_t> vi; // @@+ Compliant +@@
std::vector <bool> vb;    // @@- Non-Compliant -@@


  • HIC++ v3.3 – 17.13

Click here for references