53template<
typename T,
typename TAllocator= HeapAllocator>
70 template<
typename... TArgs,
typename TRequires= TAllocator>
71 requires std::default_initializable<TRequires>
73 :
custom(std::forward<TArgs>(args)...)
95 template<
typename... TArgs>
97 :
custom(std::forward<TArgs>(args)...)
110 using FieldMembers = std::conditional_t< std::is_default_constructible<TAllocator>::value,
154 :
members(other.members) { other.members=
nullptr; }
165 if (
this == &other || this->members == other.members)
173 if((
members= other.members) !=
nullptr)
195 other.members=
nullptr;
210 template<
typename... TArgs,
typename TRequires= TAllocator>
211 requires (!std::default_initializable<TRequires>)
213 :
members( allocator().
template New<FieldMembers>( allocator,
214 std::forward<TArgs>(args)...) ) {}
235 template <
typename... TArgs,
typename TRequires= TAllocator>
236 requires( std::default_initializable<TRequires>
237 && (
sizeof...(TArgs) > 0)
238 && (
sizeof...(TArgs) != 1
239 || !std::same_as<std::decay_t<std::tuple_element_t<0, std::tuple<TArgs...>>>,
241 && std::is_constructible_v<T, TArgs...> )
243 :
members( TAllocator()().
template New<FieldMembers>(std::forward<TArgs>(args)...) ) {}
263 return members->GetAllocator();
299 operator bool() const noexcept {
return members !=
nullptr; }
317template<
typename T,
typename TAllocator= lang::HeapAllocator>
#define ALIB_ASSERT_ERROR(cond, domain,...)
void operator=(std::nullptr_t)
Assignment of nullptr. Same as #".SetNulled".
SharedVal(std::nullptr_t) noexcept
SharedVal() noexcept
Default Constructor. Leaves this object nulled.
SharedVal & operator=(const SharedVal &other) noexcept
T StoredType
Exposes the stored type specified with template parameter T.
T & getR() const noexcept
T * getP() const noexcept
bool Unique() const noexcept
static constexpr size_t SizeOfAllocation()
bool IsNulled() const noexcept
AllocatorType & GetAllocator() const
bool operator==(std::nullptr_t) const noexcept
SharedVal(const SharedVal &other) noexcept
SharedVal & operator=(SharedVal &&other) noexcept
SharedVal(TArgs &&... args)
std::conditional_t< std::is_default_constructible< TAllocator >::value, FieldMembersNoTA, FieldMembersWithAllocator > FieldMembers
SharedVal(TAllocator &allocator, TArgs &&... args)
SharedVal(SharedVal &&other) noexcept
unsigned UseCount() const noexcept
bool operator!=(std::nullptr_t) const noexcept
TAllocator AllocatorType
Exposes the allocator as given with template parameter TAllocator.
containers::SharedVal< T, TAllocator > SharedVal
Type alias in namespace #"%alib".
Fields if TAllocator is default-constructible (e.g., #"HeapAllocator").
std::atomic< unsigned > refCount
The reference counter used to implement the std::shared_ptr behavior.
static constexpr TAllocator GetAllocator() noexcept
T custom
The instance of the custom type.
FieldMembersNoTA(TArgs &&... args)
Fields if TAllocator is not default-constructible (not #"HeapAllocator").
TAllocator & allocator
The allocator used.
FieldMembersWithAllocator(TAllocator &pAllocator, TArgs &&... args)
std::atomic< unsigned > refCount
The reference counter used to implement the std::shared_ptr behavior.
TAllocator & GetAllocator() const
T custom
The instance of the custom type.