6

C++调用std::thread(f,param),两个形参会被推导为什么类型?

 3 years ago
source link: https://www.zhihu.com/question/449953517/answer/1786290990
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
C++调用std::thread(f,param),两个形参会被推导为什么类型? - 知乎
登录一下,更多精彩内容等你发现
贡献精彩回答,参与评论互动
C++程序猿, 公众号:高级开发者

std::thread的构造函数是个泛型函数:

template< class Function, class... Args >
explicit thread( Function&& f, Args&&... args );

也就是说第一个参数为函数对象类型,第二个为函数对象的入参类型,这些都是泛型。总的来说取决于你传递的fparam的实际类型。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK