Iros
 
Loading...
Searching...
No Matches
allocate_one.h
Go to the documentation of this file.
1#pragma once
2
7#include "di/meta/vocab.h"
10
11namespace di::container {
12namespace detail {
13 template<typename T>
15 template<concepts::Allocator Alloc>
16 constexpr auto operator()(Alloc& allocator) const -> meta::AllocatorResult<Alloc, T*> {
17 if consteval {
18 return std::allocator<T>().allocate(1);
19 }
20
21 return vocab::as_fallible(di::allocate(allocator, sizeof(T), alignof(T))) % [](AllocationResult<> result) {
22 return static_cast<T*>(result.data);
24 }
25 };
26}
27
28template<typename T>
30}
31
32namespace di {
34}
Definition sequence.h:13
Definition sequence.h:12
constexpr auto allocate_one
Definition allocate_one.h:29
meta::LikeExpected< decltype(di::allocate(util::declval< Alloc & >(), 0, 0)), T > AllocatorResult
Definition allocator.h:25
constexpr auto as_fallible
Definition as_fallible.h:26
constexpr auto try_infallible
Definition try_infallible.h:31
Definition zstring_parser.h:9
constexpr auto allocate
Definition allocate.h:26
Definition allocation_result.h:7
Definition allocate_one.h:14
constexpr auto operator()(Alloc &allocator) const -> meta::AllocatorResult< Alloc, T * >
Definition allocate_one.h:16