Hi I have been learning and familiarizing with std::unique_ptr and so I decided to emulate std::vector. At line 63, I want my current vector to point at the newly created vector but I can't assign to it. Why is that?
&data is the address of the unique_pointer. You're creating a temporary variable, a pointer-to-a-unique-pointer.
&new_data is the address of the unique_pointer. You're creating a temporary variable, a pointer-to-a-unique-pointer.
You can't assign a value to a temporary. That's how C++ works. That code simply makes no sense.
It looks like you want the unique_ptr data to now point to the same thing that the unique_ptr new_data is pointing at? In which case &data, the address of the unique_ptr named data, is completely irrelevant.
If that is what you're trying to do, it's done like this: data = std::move(new_data);