fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class function_set {
  6. public:
  7. static void override() { cout << "1" << endl; }
  8. static void override( const char* ) { cout << "2" << endl; }
  9. static void override( string ) { cout << "2" << endl; }
  10. };
  11.  
  12. #define probe1( funct, ... ) funct( __VA_ARGS__ )
  13.  
  14. template < class f, class ... ax > auto probe2( f && funct, ax ... args ) -> decltype( funct( args ... ) ) {
  15. return funct( args ... );
  16. }
  17.  
  18. int main() {
  19. probe1( function_set::override, "abc" );
  20. probe2( function_set::override, "abc" );
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:40: error: no matching function for call to ‘probe2(<unresolved overloaded function type>, const char [4])’
  probe2( function_set::override, "abc" );
                                        ^
prog.cpp:20:40: note: candidate is:
prog.cpp:14:41: note: template<class f, class ... ax> decltype (funct(probe2::args ...)) probe2(f&&, ax ...)
 template < class f, class ... ax > auto probe2( f && funct, ax ... args ) -> decltype( funct( args ... ) ) {
                                         ^
prog.cpp:14:41: note:   template argument deduction/substitution failed:
prog.cpp:20:40: note:   couldn't deduce template parameter ‘f’
  probe2( function_set::override, "abc" );
                                        ^
stdout
Standard output is empty