cuda::experimental::stf::sump::when#

template<class _Pred>
struct when#

Predicate guard: when(pred)(s) restricts the sink s to the cases where pred holds.

when(pred) is itself a sink, the guard; applying it to a sink s yields when(pred) & s. There is no runtime “nop” answer on the exception path: a hook either accepts or forwards. A true predicate contributes a void effect answer so & continues; false forwards by throwing. As a | arm this means “not applicable, try the next arm”; inside &, false passes the whole sequence through. The predicate takes either nothing or the const std::exception* of the failure in flight. A guard can be named and applied to several sinks: auto transient = when(is_transient); transient(retry(3)) | transient(notify(log)). The guard holds the predicate by value: an lvalue predicate is copied, so later changes to the original do not reach the guard; pass std::ref(pred) to share one predicate object. Each application copies the predicate into the guarded sink. if_isa remains separate because its typed claims support the starved-arm theorem, while arbitrary predicates do not.

Public Functions

inline explicit when(_Pred __pred)#
template<class _P>
inline auto operator()(_P &&__p) const &#

Applies the guard to a sink: when(pred)(s) is when(pred) & s.

template<class _P>
inline auto operator()(_P &&__p) &&#
template<class _Fn>
inline void on_thrown(
const ::std::exception *__exception,
const ::cuda::std::source_location,
_Fn&
)#
template<class _Status, class _Fn, class _Self = _Pred, ::cuda::std::enable_if_t<::cuda::std::is_invocable_v<_Self&>, int> = 0>
inline detail::__status_answer<_Status> on_returned(
const _Status __status,
const ::cuda::std::source_location,
_Fn&
)#

The code-channel hook for a nullary predicate: true contributes an effect, false passes the status through.

A predicate over const std::exception* receives the status’s exception instead.