Allocate vector size with list initialization (curly braces) : <p>How can I do the equivelant of:</p>

<pre><code>#include &lt;vector&gt;

size_t bufferSize = 1024 * 1024;
std::vector&lt;unsigned char&gt; buffer(bufferSize, ' ');
</code></pre>

<p>With list (curly braced) initialization? </p>

<p>When I try to do the following:</p>

<pre><code>#include &lt;vector&gt;

size_t bufferSize = 1024 * 1024;
std::vector&lt;unsigned char&gt; buffer {bufferSize, ' '};
</code></pre>

<p>It wrongly interprets <code>bufferSize</code> as the value to be stored in the first index of the container (i.e. calls the wrong <code>std::vector</code> constructor), and fails to compile due to invalid narrowing conversion from <code>unsigned int</code> (<code>size_t</code>) to <code>unsigned char</code>.</p>
