CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Find.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "FindIf.hpp"
12
15
16namespace CeresEngine {
17
19 class FindAlgorithmFunctor : public ValueCompareAlgorithmFunctor<FindAlgorithmFunctor> {
21
30 template<class E, class P, class I, class S, class T>
31 requires(
32 // clang-format off
33 traits::is_executor_v<E> &&
34 traits::is_partitioner_v<P, I, S> &&
35 traits::is_input_iterator_v<I> &&
36 traits::is_sentinel_for_v<S, I> &&
37 traits::is_indirectly_binary_invocable_v<std::equal_to<>, T *, I>
38 // clang-format on
39 ) static I run(I first, S last, const T& v) {
40 return std::find(first, last, v);
41 }
42
55 template<class E, class P, class I, class S, class T>
56 requires(
57 // clang-format off
58 traits::is_executor_v<E> &&
59 traits::is_partitioner_v<P, I, S> &&
60 traits::is_input_iterator_v<I> &&
61 traits::is_sentinel_for_v<S, I> &&
62 traits::is_indirectly_binary_invocable_v<std::equal_to<>, T *, I>
63 // clang-format on
64 ) static Async<I> run(const E& executor, P p, I first, S last, const T& v) {
65 return FindIfAlgorithmFunctor{}.template run(executor, p, first, last, [&](const auto& element) { return element == v; });
66 }
67 };
68
70 inline constexpr FindAlgorithmFunctor find;
71
72} // namespace CeresEngine
A partitioner is a light callable object that takes a pair of iterators and returns the middle of the...
Identify traits for algorithms, like we do for other types.
Functor representing the overloads for the find function.
Definition Find.hpp:19
static Async< I > run(const E &executor, P p, I first, S last, const T &v)
Complete overload of the find algorithm.
Definition Find.hpp:64
static I run(I first, S last, const T &v)
Complete overload of the find algorithm.
Definition Find.hpp:39
Functor representing the overloads for the find_if function.
Definition FindIf.hpp:21
Value-compare algorithm overloads.
Definition ValueCompareAlgorithm.hpp:32
Definition Application.hpp:19
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
constexpr FindAlgorithmFunctor find
Finds the first element equal to another element.
Definition Find.hpp:70
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25