#pragma once #include template It Find_(const T &value, It first, It last, Tag tag) { for (; first != last; ++first) { if (*first == value) { return first; } } return last; } template It Find_(const T &value, It first, It last, std::random_access_iterator_tag) { It l = first; It r = last; while (l < r) { It mid = l + (r - l) / 2; if (value < *mid) { r = mid; } else { l = mid + 1; } } r--; if (*r == value) { return r; } return last; } template It Find(const T &value, It first, It last) { return Find_(value, first, last, typename std::iterator_traits::iterator_category()); }