title: Assign derived class unique_ptr to base class unique_ptr
body: <p>I created a custom istream derived from std::istream that uses a custom streambuf when the file is a zipped file and std::filebuf otherwise.</p>
  
  <pre><code>#mystream.h
  class my_stream: public istream {
    public:
       explicit my_stream(const std::string &amp;path);
    private:       
       std::unique_ptr&lt;std::streambuf&gt; b_;
  }
  
  #mystream.cpp
  my_stream::my_stream(const std::string &amp;path) :std::istream(nullptr) {
      if(path.substr(path.length()-6, path.length())==".gzip"){
          b_ = std::make_unique&lt;gzipbuf&gt;(path); //gzipbuf is derived from std::streambuf
      } 
      else {
          std::unique_ptr&lt;std::filebuf&gt; fb;
          fb-&gt;open(path.c_str(), std::ios::in);
          b_ = fb;
      }
      this-&gt;init(b_.get());
  }
  </code></pre>
  
  <p>I am able to assign derived class unique_ptr to base class unique_ptr at one place </p>
  
  <pre><code>b_ = std::make_unique&lt;gzipbuf&gt;(path);
  </code></pre>
  
  <p>but not at the other</p>
  
  <pre><code>b_ = fb;
  </code></pre>
  
  <p>It says</p>
  
  <pre><code>candidate function not viable: no known conversion from 'unique_ptr&lt;std::filebuf, default_delete&lt;std::basic_filebuf&lt;char&gt;&gt;&gt;' to 'unique_ptr&lt;std::basic_streambuf&lt;char&gt;, default_delete&lt;std::basic_streambuf&lt;char&gt;&gt;&gt;' for 1st argument
        operator=(unique_ptr&amp;&amp; __u) noexcept
  </code></pre>