fork download
  1. #include <vector>
  2. #include <utility>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. namespace std {
  7. template<class container>
  8. auto begin(container& rhs) -> typename container::iterator {return rhs.begin();}
  9. template<class container>
  10. auto begin(const container& rhs) -> typename container::iterator {return rhs.begin();}
  11. template<class element, int size>
  12. element* begin(element(&rhs)[size]) {return rhs;}
  13. template<class container>
  14. auto end(container& rhs) -> typename container::iterator {return rhs.end();}
  15. template<class container>
  16. auto end(const container& rhs) -> typename container::iterator {return rhs.end();}
  17. template<class element, int size>
  18. element* end(element(&rhs)[size]) {return rhs+size;}
  19. }
  20.  
  21. template<class iter1, class iter2>
  22. iter1 search(iter1 stackbegin, iter1 stackend, iter2 needlebegin, iter2 needleend)
  23. {return std::search(stackbegin, stackend, needlebegin, needleend);}
  24.  
  25. template<class iter1, class needlecontainer>
  26. iter1 search(iter1 stackbegin, iter1 stackend, const needlecontainer& needle)
  27. {return std::search(stackbegin, stackend, std::begin(needle), std::end(needle));}
  28.  
  29. template<class stackcontainer, class needlecontainer>
  30. decltype(std::begin(std::declval<stackcontainer>()))
  31. search(const stackcontainer& stack, const needlecontainer& needle)
  32. {return std::search(std::begin(stack), std::end(stack), std::begin(needle), std::end(needle));}
  33.  
  34. template<class stackcontainer, class needlecontainer>
  35. decltype(std::begin(std::declval<stackcontainer>()))
  36. search(stackcontainer& stack, const needlecontainer& needle)
  37. {return std::search(std::begin(stack), std::end(stack), std::begin(needle), std::end(needle));}
  38.  
  39. int main() {
  40. std::vector<char> str1;
  41. auto it = search(str1, "Look for this");
  42. }
Success #stdin #stdout 0s 2880KB
stdin
Standard input is empty
stdout

Standard output is empty