2#include "definitions_cxx.hpp"
3#include "util/exceptions.h"
8template <
typename T,
template <
typename>
typename Alloc>
9std::expected<std::unique_ptr<T, void (*)(T*)>, Error> allocate_unique(std::size_t n) {
11 return std::unique_ptr<T, void (*)(T*)>{Alloc<T>().allocate(n), [](T* ptr) { Alloc<T>().deallocate(ptr, 0); }};
12 }
catch (deluge::exception e) {
13 return std::unexpected{Error::INSUFFICIENT_RAM};