Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
The implementation strategy is to make the composed object meet the requirements of a completion handler by being movable, and by making it invocable so it can be used as a continuation for the asynchronous operations it launches. Rather than using实现策略是让组合对象满足完成处理器的要求:一方面要支持移动语义,另一方面要使其可调用,这样它就能作为其发起的异步操作的后续回调来使用。我们不使用 `std::bind`or或 `boost::bind`, which destroys the type information and therefore breaks the associators, we will simply pass `std::move(*this)` as the completion handler parameter for any operations that we initiate. For the move to work correctly, care must be taken to ensure that no access to data members are made after the move takes place. Here is the complete implementation of our composed operation:,因为它们会丢失类型信息,从而破坏关联器。相反,我们会直接把 `std::move(*this)` 作为完成处理器参数,传递给所发起的每个异步操作。为确保移动操作能正确工作,需要注意在移动发生之后,不能再访问任何数据成员。以下是该组合操作的完整实现: