title: Why isn't vector<bool> a STL container?
body: <p>Item 18 of Scott Meyers's book <em>Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library</em> says to avoid <code>vector &lt;bool&gt;</code> as it's not an STL container and it doesn't really hold <code>bool</code>s.</p>
  
  <p>The following code:</p>
  
  <pre><code>vector &lt;bool&gt; v; 
  bool *pb =&amp;v[0];
  </code></pre>
  
  <p>will not compile, violating a requirement of STL containers.</p>
  
  <p>Error:</p>
  
  <pre><code>cannot convert 'std::vector&lt;bool&gt;::reference* {aka std::_Bit_reference*}' to 'bool*' in initialization
  </code></pre>
  
  <p><code>vector&lt;T&gt;::operator []</code> return type is supposed to be <code>T&amp;</code>, but why is it a special case for <code>vector&lt;bool&gt;</code>?</p>
  
  <p>What does <code>vector&lt;bool&gt;</code> really consist of?</p>
  
  <p>The Item further says:</p>
  
  <pre><code>deque&lt;bool&gt; v; // is a STL container and it really contains bools
  </code></pre>
  
  <p>Can this be used as an alternative to <code>vector&lt;bool&gt;</code>?</p>
  
  <p>Can anyone please explain this?</p>