I want to use async to execute such a function in the environment of C++17.Here is my class
class Item {
public:
int v=1;
Item() {printf(" construct \n");};
Item(const Item&it) {printf(" construct copy \n");}
Item( Item&& it) {printf(" universal copy \n");}
~Item() {printf("destruction \n");}
};
Here is my function
Item func(float r) {return Item(); }
Here is my main function
int main()
{
auto sft=std::async(launch::async,func, 1);
};
Here is my problem: the compiler indicates that: "Item & item:: operator = (const item &)": attempt to reference a deleted function", However, when I remove the move construct function; it passes the compile stage, with the execution of copy construct function 2 times, could someone tell me why? I don't want to call the copy construct function, I just want to move the result to the sft. thanks a lot!