Lecture overview -- Keyboard shortcut: 'u'  Previous page: Container member types -- Keyboard shortcut: 'p'  Next page: Algorithms [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Templates and The Standard Library - slide 29 : 39

A vector specialization: vector<bool>

vector<bool> is a specialization of vector<T> that provides for compact representation of boolean vectors

vector<bool> complements the fixed-typed container bitset<N>

#include <iostream>
#include <vector>

int main(){
  using namespace std;

  vector<bool> vb;

  vb.push_back(true);  vb.push_back(true);  vb.push_back(false);
  vb.push_back(false); vb.push_back(false); vb.push_back(true);
  
  typedef vector<bool>::const_iterator VBI;

  for(VBI it = vb.begin(); it != vb.end(); it++) cout << *it;  // 110001
}