title: Moving a class derived from istream
body: <p>I'm creating a C++ <code>istream</code> with a custom <code>streambuf</code>. Trying to move this fails because the istream move constructor is protected. To get round this I derived a class from <code>istream</code>:</p>
  
  <pre><code>struct VectorCharBuf : public streambuf {
      VectorCharBuf(vector&lt;char&gt;&amp; v) {
          setg(v.data(), v.data(), v.data() + v.size());
      }
  };
  
  struct IVectorCharStream : public istream {
      IVectorCharStream(VectorCharBuf* contents_buf) : istream(contents_buf) {}
  };
  </code></pre>
  
  <p>The default move constructor for this class is not generated because it involves the</p>
  
  <blockquote>
    <p>use of deleted function 'std::basic_ios&lt;_CharT, _Traits>::basic_ios(const std::basic_ios&lt;_CharT, _Traits>&amp;) [with _CharT = char; _Traits = std::char_traits]'</p>
  </blockquote>
  
  <p>Further, if I try to declare a move constructor explicitly, as in</p>
  
  <pre><code>struct MyIStream : public istream {
      MyIStream(MyIStream&amp;&amp; str) : istream(move(str)) {}
  };
  </code></pre>
  
  <p>I get an error "invalid use of void expression". (I'm probably doing something silly in this last case, but I just can't spot it... .)</p>
  
  <p>How can I create a movable <code>istream</code>?</p>