mercredi 1 janvier 2020

std::result_of syntax kerfuffle

I have the following (CUDA) function:

__device__ auto foo(my_class& x, my_function_ptr_type y ) {
    return [gen](my_class& x) { return os.set_y(y); };
}

And I want typedef its return value's type. I've fiddling with the std::result_of syntax, and can't get it quite right. This won't work:

using foo_return_type = std::result_of<decltype(foo(my_class{}, my_function_ptr_type{nullptr}))>::type;

Nor this:

using foo_return_type = std::result_of<decltype(foo(my_class, my_function_ptr_type))>::type;

Nor this:

using foo_return_type = std::result_of<foo>::type;

What should I have as the template-argument to std::result_of?

Notes:

  • There's only one foo() in the namespace.
  • No templates are involved (other than std::result_of...)
  • C++11 or C++14, take your pick (but note that this is CUDA, so theoretically that could be an issue).
  • Compiler: NVCC 10.1

Aucun commentaire:

Enregistrer un commentaire