#include template Iterator Search(const T& value, Iterator first, Iterator last, Category) { auto cur = first; while (cur != last) { if (*cur == value) { break; } cur++; } return cur; } template Iterator Search(const T& value, Iterator first, Iterator last, std::random_access_iterator_tag) { auto cur = std::lower_bound(first, last, value); if (cur != last) { if (*cur == value) { return cur; } } return last; } template Iterator Find(const T& value, Iterator first, Iterator last) { typedef typename std::iterator_traits::iterator_category category; return Search(value, first, last, category()); }