Using a char as a vector index
<p>Say, I have a string and a vector of <code>bool</code>s. Based on the characters in the string, I want to set the corresponding vector indices to true.</p>

<pre><code>std::vector&lt;bool&gt; is_present(256, false);
for (int i = 0; i &lt; str.size(); ++i)
{
    is_present[str[i]] = true;
}
</code></pre>

<p>From what I understand, the standard does not define the signed-ness of a char. Depending on the platform, it may be signed or unsigned. On most platforms, signed char will be an 8-bit two's complement number (-128 to 127), and unsigned char will be an 8-bit unsigned integer (0 to 255).</p>

<p>If that is the case, is there a possibility that <code>str[i]</code> will return a negative number and cause a memory fault in <code>is_present[str[i]]</code>? or is the <code>char</code> getting typecast to <code>vector&lt;bool&gt;::size_type</code> which is <code>unsigned</code> and hence no problems can occur?</p>

<p>Also, is it better to use <code>vector&lt;bool&gt; is_present(pow(2, CHAR_BIT)), false)</code> instead of hardcoding it to 256?</p>
