且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么构造std :: thread时参数会移动两次

更新时间:2023-11-30 21:01:52

您通过值将参数传递给func,这应该构成第二步.显然,std::thread在调用func之前在内部又存储了一次,根据标准,AFAIK是绝对合法的.

You pass argument to func by value which should constitute the second move. Apparently std::thread stores it internally one more time before calling func, which AFAIK is absolutely legal in terms of the Standard.