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>
21using unique_ptr = std::unique_ptr<T, from::delay_delete<T>>;
22
32template <typename T, typename... Args>
33[[nodiscard]] from::unique_ptr<T> make_unique(Args&&... args) {
35 using altraits = std::allocator_traits<decltype(allocator)>;
36 T* p = altraits::allocate(allocator, 1);
37 if (!p)
38 return nullptr;
39 altraits::construct(allocator, p, std::forward<Args>(args)...);
40 return from::unique_ptr<T>{ p };
41}
42
43// Compile time size checks - failing these means binary incompatibility
44static_assert(sizeof(from::unique_ptr<std::byte>) == 8,
45 "ELDEN RING ABI requirement");
46} // namespace from
The main libER stand-in for ER allocator proxies.
Definition from_allocator.hpp:308
ELDEN RING allocation interface and from::allocator.
Delay deleter implementation.
from::unique_ptr< T > make_unique(Args &&... args)
from::unique_ptr make_unique implementation
Definition from_unique_ptr.hpp:33
std::unique_ptr< T, from::delay_delete< T > > unique_ptr
std::unique_ptr with from::allocator and from::delay_delete.
Definition from_unique_ptr.hpp:21