fork download
  1. #include <iostream>
  2.  
  3. template <typename fT>
  4. struct return_type;
  5.  
  6. template <typename R, typename ...Args>
  7. struct return_type<R(*)(Args...)>
  8. {
  9. using type = R;
  10. };
  11.  
  12. struct A
  13. {
  14. template <class T>
  15. using X = void();
  16.  
  17. template <class T>
  18. X<T> x;
  19. };
  20.  
  21. template <typename T>
  22. auto A::x() -> typename return_type< typename std::add_pointer<X<T>>::type >::type
  23. {
  24. std::cout << __PRETTY_FUNCTION__ << std::endl;
  25. }
  26.  
  27. int main()
  28. {
  29. A a;
  30.  
  31. a.x<void>();
  32. a.x<int>();
  33. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
return_type<void (*)()>::type A::x() [with T = void; return_type<void (*)()>::type = void]
return_type<void (*)()>::type A::x() [with T = int; return_type<void (*)()>::type = void]