Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <tuple>
  2.  
  3. template<class T>
  4. struct callable_trait
  5. {};
  6.  
  7. template<class R, class... Args>
  8. struct callable_trait<R(Args...)>
  9. {
  10. using return_type = R;
  11. using argument_types = std::tuple<Args...>;
  12. };
  13.  
  14. template<auto callable>
  15. using return_type = typename callable_trait<decltype(callable)>::return_type;
  16.  
  17. void f();
  18. void g(return_type<f>);
  19.  
  20. error: no type named 'return_type' in 'callable_trait<void (*)()>'
  21. using return_type = typename callable_trait<decltype(callable)>::return_type;
  22. ^~~~~
  23.  
  24. auto lambda= [](){};
  25. void h(return_type<lambda>);
  26.  
  27. error: a non-type template parameter cannot have type '(lambda at <source>:19:14)'
  28. void h(return_type<lambda>);
  29. ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement