From 9a11c337641b3d6f4b53883a1e48858b0bb628b4 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 6 Nov 2022 20:27:22 -1000 Subject: [PATCH] feat: Custom `find_first_of` algorithm added --- src/core/include/units/bits/algorithm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/include/units/bits/algorithm.h b/src/core/include/units/bits/algorithm.h index ca3877e4..92aa4200 100644 --- a/src/core/include/units/bits/algorithm.h +++ b/src/core/include/units/bits/algorithm.h @@ -60,6 +60,19 @@ constexpr auto get_first_of(const Rng& rng, UnaryFunction f) } // TODO remove all the below and use std when moved to modules +template +constexpr InputIt find_first_of(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last) +{ + for (; first != last; ++first) { + for (ForwardIt it = s_first; it != s_last; ++it) { + if (*first == *it) { + return first; + } + } + } + return last; +} + template constexpr bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) {