fork(2) download
  1. #include <iostream>
  2. #include <tuple>
  3.  
  4. using namespace std;
  5.  
  6. template <typename Ret, typename... Args>
  7. tuple<Args...> m(Ret(Args...));
  8.  
  9. template <typename Ret, typename C, typename... Args>
  10. tuple<Args...> m(Ret(C::*)(Args...));
  11.  
  12. void foo(char, short);
  13.  
  14. struct bar { void foo(char, short); };
  15.  
  16. int main() {
  17. decltype(m(foo)) test('a', 13);
  18. decltype(m(bar::foo)) test2('a', 13))
  19. cout << get<0>(test) << endl;
  20. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:18:21: error: invalid use of non-static member function 'void bar::foo(char, short int)'
     decltype(m(bar::foo)) test2('a', 13))
                     ^
prog.cpp:18:21: error: invalid use of non-static member function 'void bar::foo(char, short int)'
prog.cpp:18:40: error: expression list treated as compound expression in initializer [-fpermissive]
     decltype(m(bar::foo)) test2('a', 13))
                                        ^
prog.cpp:18:41: error: expected ',' or ';' before ')' token
     decltype(m(bar::foo)) test2('a', 13))
                                         ^
stdout
Standard output is empty