19 struct AllocateManyFunction {
20 template<concepts::Allocator Alloc>
21 constexpr auto operator()(Alloc& allocator,
usize count)
const
24 auto* result = std::allocator<T>().allocate(
count);
25 return AllocationResult<T> { result,
count };
28 if constexpr (concepts::FallibleAllocator<Alloc>) {
29 auto byte_size = math::Checked(
count) *
sizeof(T);
30 if (byte_size.invalid()) {
35 return AllocationResult<T> {
static_cast<T*
>(result.data), result.count /
sizeof(T) };
37 auto byte_size = math::Checked(
count) *
sizeof(T);
40 auto result =
di::allocate(allocator, *byte_size.value(),
alignof(T));
41 return AllocationResult<T> {
static_cast<T*
>(result.data), result.count /
sizeof(T) };
48constexpr inline auto allocate_many = detail::AllocateManyFunction<T> {};
#define DI_ASSERT(...)
Definition assert_bool.h:7
#define DI_TRY(...)
Definition monad_try.h:13
constexpr auto count
Definition count.h:37
constexpr auto allocate_many
Definition allocate_many.h:48
size_t usize
Definition integers.h:33
Unexpected(E &&) -> Unexpected< meta::UnwrapRefDecay< E > >
Definition any_storable.h:9
constexpr auto allocate
Definition allocate.h:26