我有以下(CUDA)功能:
__device__ auto foo(my_class& x, my_function_ptr_type y ) {
return [gen](my_class& x) { return x.set_y(y); };
}
我想要 typedef 它的返回值的类型。我一直在摆弄 std::result_of 语法,但不能完全正确。这不起作用:
using foo_return_type = std::result_of<decltype(foo(my_class{}, my_function_ptr_type{nullptr}))>::type;
也不是这个:
using foo_return_type = std::result_of<decltype(foo(my_class, my_function_ptr_type))>::type;
也不是这个:
using foo_return_type = std::result_of<foo>::type;
我应该有什么作为模板参数std::result_of
?
笔记:
- 命名空间中只有一个
foo()
。 - 不涉及模板(除了
std::result_of
...) - C++11 或 C++14,任你选择(但请注意,这是 CUDA,所以理论上这可能是一个问题)。
- 编译器:NVCC 10.1