fork download
  1. #include<set>
  2.  
  3. template<typename T, typename T2 = void>
  4. struct MySet
  5. {
  6. std::pair<T,bool> insert (const T& i) { return std::pair<T,bool>(T(),true); }
  7. std::pair<T,bool> insert (T&& i) { return std::pair<T,bool>(T(),true); }
  8. void insert (std::initializer_list<T> i) { return false; }
  9.  
  10. template<typename Iterator> // Newly added
  11. void insert(Iterator i, Iterator j) {}
  12. };
  13.  
  14. template<typename Return, typename T>
  15. T ReceiveFuncPtr (Return (T::*Method)(const int&))
  16. {
  17. T obj;
  18. (obj.*Method)(1);
  19. return obj;
  20. }
  21.  
  22. int main ()
  23. {
  24. ReceiveFuncPtr(&MySet<int>::insert); // OK
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:24:37: error: no matching function for call to 'ReceiveFuncPtr(<unresolved overloaded function type>)'
   ReceiveFuncPtr(&MySet<int>::insert);  // OK
                                     ^
prog.cpp:24:37: note: candidate is:
prog.cpp:15:3: note: template<class Return, class T> T ReceiveFuncPtr(Return (T::*)(const int&))
 T ReceiveFuncPtr (Return (T::*Method)(const int&))
   ^
prog.cpp:15:3: note:   template argument deduction/substitution failed:
prog.cpp:24:37: note:   mismatched types 'const int&' and 'std::initializer_list<int>'
   ReceiveFuncPtr(&MySet<int>::insert);  // OK
                                     ^
prog.cpp:24:37: note:   mismatched types 'const int&' and 'int&&'
prog.cpp:24:37: note:   couldn't deduce template parameter 'Return'
stdout
Standard output is empty