<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>
      N2353 A Specification for vector&lt;bool&gt;
    </title>
  </head>
  <body>
    <h1>
      A Specification for vector&lt;bool&gt;
    </h1>Document Number: n2353(07-0213)<br />
    2007-07-19<br />
    Alisdair Meredith &lt;public@alisdairm.net&gt;<br />
    <p></p>
    <h2>
      The Problem
    </h2>The 2003 Standard requires a partial specialization of the standard library vector
    container for bool values. This specification has a number of problems, the most significant is that the existing specification leaves the semantics of all operations completely undefined. Given there is a widespread understanding that the intent was to mandate a space-optimized implementation and that flip operations would switch values from true to false and back again this paper provides wording for the missing semantics.
    </p>
    <h2>
      Proposed changes to the working paper
    </h2>
    Add to clause 23.1.6 [vector.bool]:

    <p>
      -2- Unless described below, all operations have the same requirements and semantics as the
      primary vector template, except that operations dealing with the <code>bool</code> value type
      map to bit values in the container's storage.
    </p>
    <p>
      -3- There is no requirement that the data is stored as a contiguous allocation of
      <code>bool</code> values. A space-optimized representation of bits is recommended instead.
    </p>
    <p>
      -4- <code>reference</code> is a class that simulates the behavior of references of a single
      bit in <code>vector&lt;bool&gt;</code>. The conversion operator returns <code>true</code>
      when the bit is set, and <code>false</code> otherwise. The assignment operator sets the bit
      when the argument is (convertible to) <code>true</code> and clears it otherwise.
      <code>flip</code> reverses the state of the bit.
    </p>
    <p>
      <code>void flip()</code><br/>
      -5-  Replaces each element in the container with its complement. It is unspecified if
      it has any effect on allocated but unused bits.
    </p>
    <p></p>
  </body>
</html>
