summaryrefslogtreecommitdiff
path: root/kernel/lib/libcxx/include/__algorithm/find.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/lib/libcxx/include/__algorithm/find.h')
-rw-r--r--kernel/lib/libcxx/include/__algorithm/find.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/__algorithm/find.h b/kernel/lib/libcxx/include/__algorithm/find.h
new file mode 100644
index 0000000..c47b914
--- /dev/null
+++ b/kernel/lib/libcxx/include/__algorithm/find.h
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the BastionOS freestanding C++ standard library.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBBASTION_ALGORITHM_FIND_H
+#define _LIBBASTION_ALGORITHM_FIND_H
+
+#include <__config>
+
+_LIBBASTION_BEGIN_NAMESPACE_STD
+
+template<class _InputIt, class _Tp>
+_LIBBASTION_NODISCARD constexpr _InputIt find(_InputIt __first, _InputIt __last, const _Tp& __val) {
+ for (; __first != __last; ++__first)
+ if (*__first == __val)
+ return __first;
+ return __last;
+}
+
+template<class _InputIt, class _Pred>
+_LIBBASTION_NODISCARD constexpr _InputIt find_if(_InputIt __first, _InputIt __last, _Pred __pred) {
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ return __first;
+ return __last;
+}
+
+template<class _InputIt, class _Pred>
+_LIBBASTION_NODISCARD constexpr _InputIt find_if_not(_InputIt __first, _InputIt __last, _Pred __pred) {
+ for (; __first != __last; ++__first)
+ if (!__pred(*__first))
+ return __first;
+ return __last;
+}
+
+_LIBBASTION_END_NAMESPACE_STD
+
+#endif // _LIBBASTION_ALGORITHM_FIND_H