cuda::experimental::stf::run_once#

template<typename ...Ts>
class run_once#

A class that ensures a function is executed only once for a given set of arguments (including none).

The run_once class is a utility that caches the result of a function call based on its arguments, ensuring that the function is only run once for each unique set of arguments. It is particularly useful in scenarios where a function call is expensive and the result is invariant for the same input parameters.

Template Parameters:

Ts – Types of the arguments used to uniquely identify the function call.

Public Functions

inline run_once(Ts... val)#

Constructs the run_once object with given arguments.

These arguments are used to uniquely identify the function call.

Parameters:

val – Arguments that are used to determine if the function has been run before.

template<typename Fun>
inline auto &operator->*(Fun &&fun) &&#

Invokes the function if it has not been run with the stored arguments before.

If the function has been run before with the same arguments, returns the cached result.

Template Parameters:

Fun – The type of the function to be executed.

Parameters:

fun – The function to be executed.

Returns:

The result of the function call. The type of the result is determined by the return type of the function.