31 template <
typename First,
typename Second>
32 using Pair = std::pair<First, Second>;
37 template<
typename ...Args>
43 template<
typename T,
size_t Size>
44 using Array = std::array<T, Size>;
60 template<
typename T>
using Span = std::span<T>;
64 return {
reinterpret_cast<const char*
>(data.data()), data.size_bytes() };
80 template <
typename T,
typename ...Args>
82 T* data =
static_cast<T*
>(resource->
Allocate(size *
sizeof(
T),
alignof(
T)));
83 if constexpr (!std::is_trivially_constructible_v<T> ||
sizeof...(Args) > 0)
85 for (
size_t i = 0;
i < size;
i++)
86 std::construct_at(&data[
i], std::forward<Args>(
args)...);
96 if constexpr (!std::is_trivially_destructible_v<T>)
99 std::destroy_at(&
item);
130 using Vector = std::vector<T, StlAllocator<T>>;
139 template<
typename T,
typename Predicate = std::less<T>>
140 using Set = std::set<T, Predicate, StlAllocator<T>>;
149 template<
typename T,
typename Predicate = std::less<T>>
150 using MultiSet = std::multiset<T, Predicate, StlAllocator<T>>;
159 template<
typename K,
typename V,
typename Predicate = std::less<K>>
160 using Map = std::map<K, V, Predicate, StlAllocator<Pair<const K, V>>>;
169 template<
typename K,
typename V,
typename Predicate = std::less<K>>
170 using MultiMap = std::multimap<K, V, Predicate, StlAllocator<Pair<const K, V>>>;
179 using Deque = std::deque<T, StlAllocator<T>>;
188 using List = std::list<T, StlAllocator<T>>;
196 template<
typename T,
typename Container = Deque<T>>
197 using Queue = std::queue<T, Container>;
205 template<
typename T,
typename Predicate = std::less<T>,
typename Container = Vector<T>>
213 using namespace std::ranges;
217 template <
typename Range>
224 return std::ranges::find(
range, value) != std::ranges::end(
range);
230 template <
typename T>
233 if (
auto it = std::ranges::begin(range);
it != std::ranges::end(range))
243 using namespace std::views;
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
virtual void Deallocate(pointer ptr)=0
virtual pointer Allocate(size_type size, size_t alignment=alignof(std::max_align_t))=0
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 Container.hpp:231
Lock-free atomic primitives and implementations of data structures.
Definition Allocator.hpp:5
std::vector< T, StlAllocator< T > > Vector
std::vector with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:130
std::basic_string< char > String
Alias for std::basic_string<char>, without an explicit allocator constructor.
Definition Container.hpp:112
std::tuple< Args... > Tuple
Alias for std::tuple
Definition Container.hpp:38
std::multimap< K, V, Predicate, StlAllocator< Pair< const K, V > > > MultiMap
std::multimap with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:170
std::queue< T, Container > Queue
std::queue with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:197
std::basic_string< char, std::char_traits< char >, StlAllocator< char > > StringAlloc
std::basic_string<char> with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:120
void DestructSpan(Allocator *resource, Span< T > span)
Convenience function for destructing a Span allocated with ConstructSpan. Calls destructors in-place ...
Definition Container.hpp:95
std::pair< First, Second > Pair
Alias for std::pair
Definition Container.hpp:32
std::set< T, Predicate, StlAllocator< T > > Set
std::set with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:140
std::map< K, V, Predicate, StlAllocator< Pair< const K, V > > > Map
std::map with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:160
std::list< T, StlAllocator< T > > List
std::list with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:188
std::bitset< Size > Bitset
Alias for std::bitset
Definition Container.hpp:50
Span< T > ConstructSpan(Allocator *resource, size_t size, Args &&...args)
Convenience function for constructing a Span with memory allocated from a Foundation::Core::Allocator...
Definition Container.hpp:81
Span< const T > AsSpan(T const &data)
Helper to construct one const r-value as a single element span.
Definition Container.hpp:69
std::priority_queue< T, Container, Predicate > PriorityQueue
std::priority_queue with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:206
std::multiset< T, Predicate, StlAllocator< T > > MultiSet
std::multiset with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:150
std::array< T, Size > Array
Alias for std::array
Definition Container.hpp:44
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:55
Span< const char > AsBytes(Span< T > data)
Definition Container.hpp:62
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:149
std::span< T > Span
Alias for std::span
Definition Container.hpp:60
std::optional< T > Optional
Alias for std::optional
Definition Container.hpp:26
std::deque< T, StlAllocator< T > > Deque
std::deque with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:179
Range predicate that checks if a value is contained within a given range.
Definition Container.hpp:219
constexpr bool operator()(auto &&value) const
Definition Container.hpp:222
ContainedBy(Range const &range)
Definition Container.hpp:221
Range const & range
Definition Container.hpp:220
std::allocator adaptor for Foundation::Core::Allocator
Definition Allocator.hpp:78