SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.                    ^
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top