title: Is the use of std::vector<bool> objects in C++ acceptable, or should I use an alternative?
body: <p>I'm working with a user-defined quantity of bits (I'm holding a three-dimensional array of bits, so the size increases cubically - assume no less then 512 bits), and need to flip them each individually.  Right now, just on a computer, I'm using the <code>bool</code> type, since memory isn't an issue.  I do plan to move the code to a microcontroller in the future, and so processing power and memory requirements may be an issue.  Right now though, I just want speed.</p>
  <p>I then found the <code>std::bitset</code> object from the <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" rel="nofollow noreferrer">C++ STL</a>, but I can't define a bitset's size at runtime.  I then found that the <code>std::vector&lt;bool&gt;</code> has a special initializer to store them as bits (instead of entire bytes, or 4 bytes) but then found <a href="http://en.wikipedia.org/wiki/Vector_%28C++%29#Specialization_for_bool" rel="nofollow noreferrer">this section</a> in Wikipedia:</p>
  <blockquote>
  <p>The Standard Library defines a specialization of the <code>vector</code> template
  for <code>bool</code>. The description of this specialization indicates that the
  implementation should pack the elements so that every <code>bool</code> only uses
  <em>one bit</em> of memory. This is widely considered a mistake. [...] There is a general consensus among the C++ Standard Committee and the Library Working Group that <code>vector&lt;bool&gt;</code> should be deprecated and subsequently removed from the standard library, while the functionality will be reintroduced under a different name.</p>
  </blockquote>
  <p>Now, you can probably see my want for using a <code>vector&lt;bool&gt;</code> object, but after reading that, I'm considering using something else.  The only problem is that I'm not sure <em>what</em> to use.  I was curious though why they state that the functionality <em>should</em> be re-introduced (albeit under a different name).</p>
  <p>So, my question is, would the use of <code>vector&lt;bool&gt;</code> objects be acceptable (being that they are a part of the STL)?  Are they a part of the C++ standard?</p>
  <p>If their use is not acceptable, is there an acceptable, alternative solution (outside me defining a special container myself)?  I have a few ideas myself, but I'm just curious if anyone has a better solution.  Also, I would like to avoid using large libraries (again, I want to eventually port this code to a microcontroller).</p>