Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
ref_counted.hpp File Reference
#include <helios/assert.hpp>
#include <atomic>
#include <concepts>
#include <cstdint>
#include <memory>
#include <memory_resource>
#include <type_traits>

Go to the source code of this file.

Classes

class  helios::mem::RcFromThis< Derived >
 CRTP base class that embeds a non-atomic reference counter into the derived type. More...
class  helios::mem::ArcFromThis< Derived >
 CRTP base class that embeds an atomic reference counter into the derived type. More...
class  helios::mem::RefCounted< Derived, Allocator >
 Non-atomic intrusive reference-counted smart pointer. More...
class  helios::mem::AtomicRefCounted< Derived, Allocator >
 Thread-safe intrusive reference-counted smart pointer. More...

Namespaces

namespace  helios
namespace  helios::mem

Typedefs

template<typename T, typename Allocator = std::allocator<T>>
using helios::mem::Rc = RefCounted<T, Allocator>
 Alias for RefCounted<T> — non-atomic intrusive reference-counted handle.
template<typename T, typename Allocator = std::allocator<T>>
using helios::mem::Arc = AtomicRefCounted<T, Allocator>
 Alias for AtomicRefCounted<T> — thread-safe intrusive reference-counted handle.
template<typename T>
using helios::mem::PmrRc = RefCounted<T, std::pmr::polymorphic_allocator<T>>
 Alias for RefCounted<T> using polymorphic memory allocator.
template<typename T>
using helios::mem::PmrArc = AtomicRefCounted<T, std::pmr::polymorphic_allocator<T>>
 Alias for AtomicRefCounted<T> using polymorphic memory allocator.

Functions

template<typename T, typename... Args>
requires std::derived_from<T, RcFromThis<T>> && std::constructible_from<T, Args...>
auto helios::mem::MakeRc (Args &&... args) -> Rc< T >
 Allocates and constructs a T object, returning a Rc<T, std::allocator<T>> handle.
template<typename T, typename... Args>
requires std::derived_from<T, ArcFromThis<T>> && std::constructible_from<T, Args...>
auto helios::mem::MakeArc (Args &&... args) -> Arc< T >
 Allocates and constructs a T object, returning an Arc<T, std::allocator<T>> handle.
template<typename T, typename Allocator, typename... Args>
requires std::derived_from<T, RcFromThis<T>> && std::constructible_from<T, Args...> && (!std::derived_from<std::remove_pointer_t
<Allocator>, std::pmr::memory_resource>)
auto helios::mem::MakeRcWith (Allocator alloc, Args &&... args) -> Rc< T, Allocator >
 Overload of MakeRc accepting a pre-constructed allocator instance.
template<typename T, typename... Args>
requires std::derived_from<T, RcFromThis<T>> && std::constructible_from<T, Args...>
auto helios::mem::MakeRcWith (std::pmr::memory_resource *resource, Args &&... args) -> PmrRc< T >
 Allocates and constructs a T object using PMR memory resource, returning a PmrRc<T> handle.
template<typename T, typename... Args>
auto helios::mem::MakeRcWith (std::nullptr_t, Args &&...) -> PmrRc< T >=delete
template<typename T, typename Allocator, typename... Args>
requires std::derived_from<T, ArcFromThis<T>> && std::constructible_from<T, Args...> && (!std::derived_from<std::remove_pointer_t
<Allocator>, std::pmr::memory_resource>)
auto helios::mem::MakeArcWith (Allocator alloc, Args &&... args) -> Arc< T, Allocator >
 Overload of MakeArc accepting a pre-constructed allocator instance.
template<typename T, typename... Args>
requires std::derived_from<T, ArcFromThis<T>> && std::constructible_from<T, Args...>
auto helios::mem::MakeArcWith (std::pmr::memory_resource *resource, Args &&... args) -> PmrArc< T >
 Allocates and constructs a T object using PMR memory resource, returning a PmrArc<T> handle.
template<typename T, typename... Args>
auto helios::mem::MakeArcWith (std::nullptr_t, Args &&...) -> PmrArc< T >=delete