xiaoweiChen / CPP-Concurrency-In-Action-2ed-2019

:book: 作为对《C++ Concurrency in Action - SECOND EDITION》的中文翻译。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

翻译错误:2.1.1

FlashPanda opened this issue · comments

原文如下:
This is about as simple as it gets. Of course, you have to make sure that the
header is included so the compiler can see the definition of the std::thread class. As
with much of the C++ Standard Library, std::thread works with any callable type, so
you can pass an instance of a class with a function call operator to the std::thread
constructor instead:

译文如下:
为了让编译器识别std::thread类,这个简单的例子也要包含头文件。如同大多数C++标准库一样,std::thread可以用可调用类型构造,将带有函数调用符类型的实例传入std::thread类中,替换默认的构造函数。

错误位置:
so you can pass an instance of a class with a function call operator to the std::thread
constructor instead
这里指的并不是替换默认构造函数,这个instead指的是用类实例的函数调用运算符替换普通的函数,就是前面定义的do_some_work函数。

这里的翻译确实有偏差。
不过,an instance of a class with a function call operator指得并不是do_some_work函数,而是下面具有函数操作符的background_task类。

我指的是instead的东西,他是要替换的do_some_work,用an instance of a class with a function call operator来instead掉do_some_work

ok,那明白了。修改后的翻译,和你的意思应该是等价的。