fork(2) download
  1. #include<set>
  2.  
  3. template<typename Return, typename T>
  4. T ReceiveFuncPtr (Return (T::*Method)(const int&))
  5. {
  6. T obj;
  7. (obj.*Method)(1);
  8. return obj;
  9. }
  10.  
  11. int main ()
  12. {
  13. ReceiveFuncPtr(&std::set<int>::insert); // ERROR
  14. }
  15.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13:40: error: no matching function for call to 'ReceiveFuncPtr(<unresolved overloaded function type>)'
   ReceiveFuncPtr(&std::set<int>::insert); // ERROR
                                        ^
prog.cpp:13:40: note: candidate is:
prog.cpp:4:3: note: template<class Return, class T> T ReceiveFuncPtr(Return (T::*)(const int&))
 T ReceiveFuncPtr (Return (T::*Method)(const int&))
   ^
prog.cpp:4:3: note:   template argument deduction/substitution failed:
prog.cpp:13:40: note:   mismatched types 'const int&' and 'std::initializer_list<int>'
   ReceiveFuncPtr(&std::set<int>::insert); // ERROR
                                        ^
prog.cpp:13:40: note:   mismatched types 'const int&' and 'std::set<int>::const_iterator {aka std::_Rb_tree_const_iterator<int>}'
prog.cpp:13:40: note:   mismatched types 'const int&' and 'std::set<int>::const_iterator {aka std::_Rb_tree_const_iterator<int>}'
prog.cpp:13:40: note:   mismatched types 'const int&' and 'std::set<int>::value_type&& {aka int&&}'
prog.cpp:13:40: note:   couldn't deduce template parameter 'Return'
stdout
Standard output is empty