invoke-result

invoke_result to obtain return type of template member function

ぃ、小莉子 提交于 2020-01-03 11:02:25
问题 How can I obtain the result type of a template member function? The following minimal example illustrates the problem. #include <type_traits> template <typename U> struct A { }; struct B { template <typename F = int> A<F> f() { return A<F>{}; } using default_return_type = std::invoke_result_t<decltype(f)>; }; int main() { B::default_return_type x{}; return 0; } See it live on Coliru. The code does not compile, giving error: main.cpp:11:63: error: decltype cannot resolve address of overloaded