diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-04-24 02:20:06 +0300 |
---|---|---|
committer | Ivan Komissarov <abbapoh@gmail.com> | 2021-04-24 02:20:06 +0300 |
commit | a8bbaf016dc3092f6f6ad0c4a333e595da665983 (patch) | |
tree | 6b1b74bbca7850ed75da01cba5a72618f3cfa94b /src/lib/corelib/tools/stlutils.h | |
parent | 001bf31623c02ba8249dd066777d014d546eb7f9 (diff) | |
parent | 2f6eecdc96fcd693cecef8011d8f9500c7872fc7 (diff) |
Merge branch '1.19' into master
Change-Id: Ic6087168a1d93c2a2b46de825f5c3b9655634e8e
Diffstat (limited to 'src/lib/corelib/tools/stlutils.h')
-rw-r--r-- | src/lib/corelib/tools/stlutils.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/corelib/tools/stlutils.h b/src/lib/corelib/tools/stlutils.h index 1b6d7278f..d4c569a95 100644 --- a/src/lib/corelib/tools/stlutils.h +++ b/src/lib/corelib/tools/stlutils.h @@ -123,6 +123,21 @@ bool none_of(const Container &container, const UnaryPredicate &predicate) return std::none_of(std::begin(container), std::end(container), predicate); } +template <class It, class T, class Compare> +It binaryFind(It begin, It end, const T &value, Compare comp) +{ + const auto it = std::lower_bound(begin, end, value, comp); + if (it == end || comp(value, *it)) + return end; + return it; +} + +template <class It, class T> +It binaryFind(It begin, It end, const T &value) +{ + return binaryFind(begin, end, value, std::less<T>()); +} + template <class C> C &operator<<(C &container, const typename C::value_type &v) { |