std::thread传入引用值需要使用std::ref[ref][cpp]
1 std::thread传入引用值需要使用std::ref
std::ref的说明: Constructs an object of the appropriate reference_wrapper type to hold a reference to elem.
其实主要是,如果要向thread传参的时候,该参数在线程内会被修改,需要用这个ref作为一个wrapper将对象包裹成为一个引用然后传入。
void main() {
while(1){
...<省略>
原创
2021-08-28 17:43:28 ·
1489 阅读 ·
0 评论