fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. template<typename T, typename C>
  7. bool IsIn(const T& t, const C& c)
  8. {
  9. return std::find(begin(c), end(c), t) != end(c);
  10. }
  11.  
  12. int main() {
  13. int check = 2;
  14. auto v = {1, 2, 3};
  15. if (std::find(v.begin(), v.end(), check) != v.end())
  16. cout << "found" << endl;
  17.  
  18. if (IsIn(check, v))
  19. cout << "found too" << endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
found
found too