Read a binary file into a std::vector<uint16_t> instead of std::vector<char>
<p>I want to read a binary file containing uint16_t values. What I've done so far is:</p>

<pre><code>std::ifstream is;
std::vector&lt;char&gt; rawfilebuffer; /* should be std::vector&lt;uint16_t&gt; */

is.open("uint16_t_file.raw", std::ios::binary);
is.seekg(0, std::ios::end);
size_t filesize=is.tellg();
is.seekg(0, std::ios::beg);

rawfilebuffer.reserve(filesize);
rawfilebuffer.assign(std::istreambuf_iterator&lt;char&gt;(is),
                     std::istreambuf_iterator&lt;char&gt;());
</code></pre>

<p>Using <code>std::istreambuf_iterator&lt;char&gt;</code>does not work (<code>error: no matching conversion for functional-style cast from 'std::ifstream'</code>).</p>

<p>Is it possible to cast istreambuf_iterator to <code>uint16_t</code>?</p>