共用方式為


operator|| Operator

Creates a task that will complete successfully when either of the tasks supplied as arguments completes successfully.

template<
   typename _ReturnType
>
task<_ReturnType> operator||(
   const task<_ReturnType> & _Lhs,
   const task<_ReturnType> & _Rhs
);

template<
   typename _ReturnType
>
task<std::vector<_ReturnType>> operator||(
   const task<std::vector<_ReturnType>> & _Lhs,
   const task<_ReturnType> & _Rhs
);

template<
   typename _ReturnType
>
task<std::vector<_ReturnType>> operator||(
   const task<_ReturnType> & _Lhs,
   const task<std::vector<_ReturnType>> & _Rhs
);

inline task<void> operator||(
   const task<void> & _Lhs,
   const task<void> & _Rhs
);

Parameters

  • _ReturnType
    The type of the returned task.

  • _Lhs
    The first task to combine into the resulting task.

  • _Rhs
    The second task to combine into the resulting task.

Return Value

A task that completes sucessfully when either of the input tasks has completed successfully. If the input tasks are of type T, the output of this function will be a task<std::vector<T>. If the input tasks are of type void the output task will also be a task<void>.

Remarks

If both of the tasks are canceled or throw exceptions, the returned task will complete in the canceled state, and one of the exceptions, if any are encountered, will be thrown when you call get() or wait() on that task.

Requirements

Header: ppltasks.h

Namespace: concurrency

See Also

Reference

concurrency Namespace

Concepts

Task Parallelism (Concurrency Runtime)