cuda::experimental::stf::sump::thrown#

template<class _E = ::std::exception, class _X>
auto cuda::experimental::stf::sump::thrown(
_X &&__x
)#

The exception channel, as a selector or as a conversion.

Given a policy, thrown(p) applies p to exceptions only and forwards a failing status. For a callable that can fail both ways, it pairs with returned, as in returned(subst(cudaSuccess)) | thrown(notify & fwd). Such a policy is built for that callable: on a bare status operand the thrown arm can never match, which is a compile error (a type selector on a status), so the same policy variable cannot be reused there.

Given a function, thrown<E>(f) converts: for an exception matching E by catch-clause rules (same or publicly derived), the answer is f(e), with e the caught const E&; anything else forwards. A value substitutes, void is Nothing, nullval never returns, and a throw from f replaces the exception. E defaults to std::exception:

thrown<cuda_exception>([](const cuda_exception& e) { return e.status<cudaError_t>(); })
  | thrown([](const std::exception&) { return cudaErrorUnknown; })

Parameters:

__x – [in] The policy, or the function taking const E&.

Returns:

The selector or converter policy.