fork(2) download
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. template<class T> class CList : public std::list<T>
  8. {
  9. public:
  10.  
  11. template<class Pred> bool Contain(Pred p)
  12. {
  13. return std::find_if(this->begin(), this->end(), p) != this->end();
  14. }
  15.  
  16.  
  17. bool Contain(const T & v)
  18. {
  19. return std::find(this->begin(), this->end(), v) != this->end();
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25. CList<int> a;
  26. a.Contain([](auto i){ return i == 5; }); //ok
  27. a.Contain(5); //term does not evaluate to a function taking 1 arguments
  28. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty