fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. struct Test
  5. {
  6. void f();
  7. template<typename T>
  8. using verify = typename std::enable_if<std::is_same<T, T>::value, T>::type;
  9. template<typename T, typename R, typename... Args>
  10. using MFP = R (verify<T>::*)(Args...);
  11. template<typename T, typename R, typename... Args>
  12. static MFP<T, R, Args...> g(MFP<T, R, Args...> mf){return mf;}
  13. };
  14.  
  15. int main()
  16. {
  17. auto test = Test::g(&Test::f);
  18. }
  19.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17:30: error: no matching function for call to ‘Test::g(void (Test::*)())’
  auto test = Test::g(&Test::f);
                              ^
prog.cpp:17:30: note: candidate is:
prog.cpp:12:28: note: template<class T, class R, class ... Args> static R (std::enable_if<std::is_same<_Tp, _Tp>::value, T>::type::* Test::g(Test::MFP<T, R, Args ...>))(Args ...)
  static MFP<T, R, Args...> g(MFP<T, R, Args...> mf){return mf;}
                            ^
prog.cpp:12:28: note:   template argument deduction/substitution failed:
prog.cpp:17:30: note:   couldn't deduce template parameter ‘T’
  auto test = Test::g(&Test::f);
                              ^
stdout
Standard output is empty