into_kernel_arg

template<typename T>
KernelArg kernel_launcher::into_kernel_arg(T &&value)

Convert the given value into a KernelArg. This is done by calling IntoKernelArg<T>::convert(value) which, by default, just calls KernelArg::from_scalar<T>(value).

It is possible to overload this function by specializing IntoKernelArg. For example:

namespace kernel_launcher {
template <>
struct IntoKernelArg<mypackage::MyIntegerType> {
  static KernelArg convert(mypackage::MyIntegerType m) {
    return KernelArg::from_scalar(m.to_int());
  }
};

template <>
struct IntoKernelArg<mypackage::MyArrayType> {
  static KernelArg convert(mypackage::MyArrayType arr) {
    return KernelArg::from_array(arr.ptr(), arr.length());
  }
};
}