cuda::experimental::stf::only_convertible
Defined in include/cuda/experimental/__stf/utility/traits.cuh
-
template<typename T, typename P0, typename ...P>
T cuda::experimental::stf::only_convertible(P0 &&p0, P&&... p) Extracts and returns the first argument from a parameter pack that is convertible to type
T
.This function template recursively inspects each argument in a parameter pack until it finds the first argument that can be converted to type
T
. It statically asserts that only one such convertible argument exists in the parameter pack to ensure uniqueness.int i = 42; double d = 3.14; std::string s = "hello"; // The following call will return 's'. auto result = only_convertible<std::string>(i, d, s);
Note
This function will cause a compile-time error if more than one argument in the parameter pack is convertible to type
T
.- Template Parameters
T – The target type to which the argument should be convertible.
P0 – The type of the first argument in the parameter pack.
P – Variadic template representing the rest of the arguments in the parameter pack.
- Parameters
p0 – The first argument in the parameter pack.
p – The remaining arguments in the parameter pack.
- Returns
T
A copy or reference to the first argument that is convertible to typeT
.