libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
from_unique_ptr.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <concepts>
13#include <memory>
14
15namespace from {
20template <typename T,
21 typename AllocatorTag = from::default_empty_base_allocator_tag>
22using unique_ptr = std::unique_ptr<T, from::delay_delete<T, AllocatorTag>>;
23
34template <typename T,
35 typename AllocatorTag = from::default_empty_base_allocator_tag,
36 typename... Args>
37[[nodiscard]] from::unique_ptr<T, AllocatorTag> make_unique(Args&&... args) {
38 using allocator_type = from::allocator<T, AllocatorTag>;
39 allocator_type allocator;
40 T* p = allocator.allocate(1);
41 std::allocator_traits<allocator_type>::construct(allocator, p,
42 std::forward<Args>(args)...);
44}
45
46// Compile time size checks - failing these means binary incompatibility
47static_assert(sizeof(from::unique_ptr<char>) == 8,
48 "ELDEN RING ABI requirement");
50 "ELDEN RING ABI requirement");
51} // namespace from
The main libER stand-in for ER allocator proxies.
Definition from_allocator.hpp:310
T * allocate(size_type n)
Allocate n instances of uninitialized memory for T.
Definition from_allocator.hpp:388
ELDEN RING allocation interface and from::allocator.
Delay deleter implementation.
from::unique_ptr< T, AllocatorTag > make_unique(Args &&... args)
from::unique_ptr make_unique implementation
Definition from_unique_ptr.hpp:37
std::unique_ptr< T, from::delay_delete< T, AllocatorTag > > unique_ptr
std::unique_ptr with from::allocator and from::delay_delete.
Definition from_unique_ptr.hpp:22
Default libER allocator with an empty base.
Definition from_allocator.hpp:294