Foundation
Loading...
Searching...
No Matches
Ranges.hpp
Go to the documentation of this file.
1#pragma once
2#include <Core/Core.hpp>
3#include <ranges>
4namespace Foundation::Bits
5{
6 using namespace Core;
10 namespace Ranges
11 {
12 using namespace std::ranges;
16 template <typename Range>
18 {
19 Range const& range;
21 constexpr bool operator()(auto&& value) const
22 {
23 return std::ranges::find(range, value) != std::ranges::end(range);
24 }
25 };
29 template <typename T>
31 {
32 if (auto it = std::ranges::begin(range); it != std::ranges::end(range))
33 return *it;
34 return {};
35 }
36 } // namespace Ranges
40 namespace Views
41 {
42 using namespace std::views;
43 } // namespace Views
44} // namespace Foundation::Bits
constexpr Optional< range_value_t< T > > FirstOf(T &&range)
Returns the first element of a range, or an empty Optional if the range is empty.
Definition Ranges.hpp:30
Header-only convenience utilities.
Definition Chrono.hpp:3
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
Range predicate that checks if a value is contained within a given range.
Definition Ranges.hpp:18
constexpr bool operator()(auto &&value) const
Definition Ranges.hpp:21
Range const & range
Definition Ranges.hpp:19
ContainedBy(Range const &range)
Definition Ranges.hpp:20