mercredi 17 juin 2020

How to invoke the template function in a loop manner?

This question is mostly about the design approach, and I would like to know how to solve such kind of problems in the modern C++ language.

I have a library function that defined like (this is a real code from the compiler):

template <info::device param>
typename info::param_traits<info::device, param>::return_type
get_info() const;

In order to call this function, I could write something like:

some_device.get_info<cl::sycl::info::device::device_type>()

where cl::sycl::info::device::device_type is an actual parameter.

There a long list of supported parameters and I would like to have a collection of result values (results of different function calls).

At this moment, I could do something like:

some_device.get_info<cl::sycl::info::device::param1>()
some_device.get_info<cl::sycl::info::device::param2>()
...
some_device.get_info<cl::sycl::info::device::paramN>()

but because this is terrible, I am looking for a better solution in C++ 11/14.

Aucun commentaire:

Enregistrer un commentaire