title: assigning an unique_ptr with std::move not working
body: <p>i am quite new to c++ and smart pointers, but it is my understanding that i can assign an unique_ptr with std::move(another unique_ptr).
  when i try to assign a unique_ptr with std::move(..) it throws the following error:</p>
  
  <blockquote>
    <p>binary '=': no operator found which takes a right-hand operand of type 'std::unique_ptr&lt;T [],std::default_delete&lt;_Ty>>'</p>
  </blockquote>
  
  <p>the following code block is where the error is thrown, on the second last line.</p>
  
  <pre><code>template&lt;typename T&gt;
  void wave::WaveReader::readSamples(std::istream&amp; input, int nr_of_bytes)
  {
      std::unique_ptr&lt;T[]&gt; a = std::make_unique&lt;T[]&gt;(this-&gt;data_chunk.subChunk2Size);
      input.read(reinterpret_cast&lt;char*&gt;(this-&gt;data.data.get()), this-&gt;data_chunk.subChunk2Size);
      this-&gt;data.length = (this-&gt;fmt.bitsPerSample / (nr_of_bytes * 8));
      this-&gt;data.width = this-&gt;data_chunk.subChunk2Size / (this-&gt;fmt.bitsPerSample / 8);
      this-&gt;data.data = std::move(a);
      std::cout &lt;&lt; sizeof(T) &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>some extra code:</p>
  
  <pre><code>class WaveReader
  {
  private:
      RIFFCHUNK riff;
      FMTCHUNK fmt;
      DATACHUNK data_chunk;
      Array&lt;int8_t&gt; data;
      std::variant&lt;Array&lt;int8_t&gt;,Array&lt;uint16_t&gt;,Array&lt;uint32_t&gt;&gt; samples;
  public:
      void read(std::string filepath);
  private:
      void readSamples(std::istream&amp; input);
      template&lt;typename T&gt;
      void readSamples(std::istream&amp; input,int nr_of_bytes);
      std::string getDataChunkID(DATACHUNK&amp; data);
      void read_RIFFCHUNK(std::istream&amp; input, RIFFCHUNK&amp; riff);
      void read_FMTCHUNK(std::istream&amp; input, FMTCHUNK&amp; fmt);
      void read_DATACHUNK(std::istream&amp; input, DATACHUNK&amp; data, FMTCHUNK&amp; fmt);
  };
  </code></pre>
  
  <p>the array class with the unique_ptr i am trying to assign to</p>
  
  <pre><code>template &lt;typename T&gt;
  struct Array
  {
      std::unique_ptr&lt;T[]&gt; data;
      uint32_t length;
      uint32_t width;
      Array(int width, int length) : width(width), length(length)
      {
          data = std::make_unique&lt;T[]&gt;(width);
      }
      Array() : width(0), length(0)
      {
          data = std::make_unique&lt;T[]&gt;(0);
      }
      T operator[](const Position&amp; pos) { return data[(pos.x * length) + pos.y]; }
  };
  </code></pre>
  
  <p>extra code:
  this code reads the file</p>
  
  <pre><code>void wave::WaveReader::read(std::string filename)
  {
      std::ifstream file(filename, std::ios::binary);
      //read riff chunk
      read_RIFFCHUNK(file, this-&gt;riff);
      //read fmt chunk
      read_FMTCHUNK(file, this-&gt;fmt);
      //read data chunk, fills data object
      read_DATACHUNK(file, this-&gt;data_chunk, fmt);
      this-&gt;readSamples(file);
  }
  </code></pre>
  
  <p>i use this code to determine what type the samples get stored in</p>
  
  <pre><code>void wave::WaveReader::readSamples(std::istream&amp; input)
  {
      //get Type
      switch (fmt.bitsPerSample)
      {
      case 8:
          readSamples&lt;uint8_t&gt;(input,1);
          break;
      case 16:
          readSamples&lt;int16_t&gt;(input, 2);
          break;
      case 24:
          readSamples&lt;int32_t&gt;(input, 3);
          break;
      case 32:
          readSamples&lt;int32_t&gt;(input, 4);
          break;
      default:
          abort(); // need to change this probably
      }
  }
  </code></pre>
  
  <p>when i change std::unique_ptr in the array struct to a normal int it does work correctly. when i change it to a T it doesn't work.</p>