26 template<
typename Hybr
idStorage, concepts::Allocator Alloc>
34 template<
typename Hybr
idStorage, concepts::Allocator Alloc>
42 "HybridStorage only supports MoveOnly and Immovable objects");
48 template<
typename, concepts::Allocator>
55 return sizeof(T) <= inline_size &&
alignof(T) <= inline_align &&
73 template<
typename Any,
typename T,
typename... Args>
78 self->m_pointer = ::new T(di::forward<Args>(args)...);
88 auto* pointer = *result;
91 self->m_pointer = pointer;
94 template<
typename T,
typename... Args>
98 self->
m_pointer = ::new T(di::forward<Args>(args)...);
121 if (!vtable.empty()) {
122 auto const fp = vtable[
Manage {}];
123 fp(source, dest, source, dest->m_allocator);
129 template<concepts::VTableFor<Interface> VTable>
135 dest_vtable = source_vtable;
140 if (!vtable.empty()) {
141 auto const fp = vtable[
Manage {}];
142 fp(self, self,
nullptr, self->m_allocator);
156 return static_cast<T*
>(address());
168 return static_cast<T const*
>(address());
173 auto address() ->
void* {
return static_cast<void*
>(util::addressof(
m_storage[0])); }
174 auto address() const ->
void const* {
return static_cast<void const*
>(util::addressof(
m_storage[0])); }
180 [[no_unique_address]] Alloc m_allocator {};
184 template<
typename Hybr
idStorage, concepts::Allocator Alloc>
187 Alloc& allocator)
const {
199 auto* a_value =
static_cast<T*
>(pointer);
215 auto* a_value =
static_cast<T*
>(pointer);
223 auto* b_value = bs->template down_cast<T>();
224 auto* a_value = as->template down_cast<T>();
232 auto* a_value = as->template down_cast<T>();
#define DI_ASSERT(...)
Definition assert_bool.h:7
Definition operations.h:11
Definition allocator.h:20
Definition operations.h:43
Definition vtable_for.h:17
constexpr auto hybrid_storage_manage
Definition hybrid_storage.h:35
StorageCategory
Definition storage_category.h:4
@ Immovable
Definition storage_category.h:8
@ MoveOnly
Definition storage_category.h:9
meta::Type< AnyT< UserInterface, Storage, VTablePolicy > > Any
Definition any.h:294
constexpr auto exchange(T &object, U &&new_value) -> T
Definition exchange.h:8
constexpr auto destroy_at
Definition destroy_at.h:24
constexpr auto construct_at
Definition construct_at.h:27
constexpr auto as_fallible
Definition as_fallible.h:26
constexpr auto try_infallible
Definition try_infallible.h:31
Unexpected(E &&) -> Unexpected< meta::UnwrapRefDecay< E > >
constexpr auto allocate_one
Definition allocate_one.h:29
constexpr auto destroy
Definition destroy.h:35
constexpr auto in_place_type
Definition in_place_type.h:12
constexpr auto deallocate_one
Definition deallocate_one.h:27
Definition hybrid_storage.h:40
void * m_pointer
Definition hybrid_storage.h:177
static constexpr void move_construct(concepts::VTableFor< Interface > auto &vtable, HybridStorage *dest, HybridStorage *source)
Definition hybrid_storage.h:117
meta::List< Manage > Interface
Definition hybrid_storage.h:46
meta::Type< detail::HybridStorageManage< HybridStorage, Alloc > > Manage
Definition hybrid_storage.h:45
static constexpr auto creation_is_fallible(InPlaceType< T >) -> bool
Definition hybrid_storage.h:60
constexpr auto down_cast() const -> T const *
Definition hybrid_storage.h:161
static constexpr auto creation_is_inline(InPlaceType< T >) -> bool
Definition hybrid_storage.h:54
meta::Conditional< creation_is_fallible(in_place_type< T >), meta::AllocatorResult< Alloc >, void > CreationResult
Definition hybrid_storage.h:65
static constexpr auto storage_category() -> StorageCategory
Definition hybrid_storage.h:51
static constexpr void move_assign(VTable &dest_vtable, HybridStorage *dest, VTable &source_vtable, HybridStorage *source)
Definition hybrid_storage.h:130
static constexpr void destroy(concepts::VTableFor< Interface > auto &vtable, HybridStorage *self)
Definition hybrid_storage.h:139
static constexpr void create(InPlaceType< Any >, meta::LikeExpected< CreationResult< T >, Any > &self, InPlaceType< T >, Args &&... args)
Definition hybrid_storage.h:75
static constexpr auto init(HybridStorage *self, InPlaceType< T >, Args &&... args)
Definition hybrid_storage.h:96
byte m_storage[inline_size]
Definition hybrid_storage.h:178
auto operator=(HybridStorage const &) -> HybridStorage &=delete
constexpr auto down_cast() -> T *
Definition hybrid_storage.h:149
HybridStorage(HybridStorage const &)=delete
Definition hybrid_storage.h:27
constexpr void operator()(T &, HybridStorage *, HybridStorage *, Alloc &) const
Definition hybrid_storage.h:186
Method< HybridStorageManage, void(This &, HybridStorage *, HybridStorage *, Alloc &)> Type
Definition hybrid_storage.h:28
Definition in_place_type.h:5