This error is from Visual Studio, and happens when you try to call a method with move semantics (&&
) and the type doesn’t understand it has to be moved.
Consider this code:
#include <memory> // Struct to hold our data struct Data { int id = 0; }; // Typedef of our unique pointer typedef std::unique_ptr<Data> Data_ptr; void doProcess(Data_ptr && data) { // Some code } int main() { Data_ptr data(new Data()); doProcess(data); // C2446 return 0; }
If we change the highlighted line to doProcess(std::move(data));
the program will build just fine.
int main() { Data_ptr data(new Data()); doProcess(data); // C2446 Data_ptr otherdata(new Data()); doProcess(std::move(otherdata)); return 0; }