|
| | AnyBase (AnyBase &&other) noexcept(detail::kAnyNoexcept) |
| | Move constructor.
|
|
| AnyBase (const AnyBase &)=delete |
| | Copy constructor deleted when Copyable is false (move-only variant).
|
| | AnyBase (const AnyBase &other) |
| | Copy constructor (only when Copyable is true).
|
template<typename T, typename... Args>
requires (isStorable<std::decay_t<T>>()) |
| | AnyBase (std::in_place_type_t< T >, Args &&... args) |
| | Construct with in-place type construction.
|
template<typename T>
requires (!std::is_base_of_v<AnyBaseAll, std::decay_t<T>> && isStorable<std::decay_t<T>>()) |
| | AnyBase (T &&value) |
| | Construct from any value type.
|
| template<typename T> |
| T & | as () |
| | Get reference to stored value of specified type.
|
| template<typename T> |
| const T & | as () const |
| | Get const reference to stored value of specified type.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| B * | asBase () |
| | Get a pointer to the stored value as Base*, regardless of its concrete type.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| const B * | asBase () const |
| | Get a const pointer to the stored value as Base*.
|
| template<typename T> |
| T * | asPtr () |
| | Get pointer to stored value of specified type.
|
| template<typename T> |
| const T * | asPtr () const |
| | Get const pointer to stored value of specified type.
|
template<typename T, typename... Args>
requires (isStorable<std::decay_t<T>>()) |
| T & | emplace (Args &&... args) |
| | Construct a new value in place, destroying any existing value.
|
| | operator bool () const |
| | Check if the AnyBase contains a value.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| B & | operator* () |
| | Dereference to the stored value as Base&.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| const B & | operator* () const |
| | Dereference to the stored value as const Base&.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| B * | operator-> () |
| | Member access on the stored value as Base*.
|
template<typename B = Base>
requires (!std::is_void_v<B>) |
| const B * | operator-> () const |
| | Member access on the stored value as const Base*.
|
| AnyBase & | operator= (AnyBase &&other) noexcept(detail::kAnyNoexcept) |
| | Move assignment operator.
|
|
AnyBase & | operator= (const AnyBase &)=delete |
| | Copy assignment deleted when Copyable is false (move-only variant).
|
| AnyBase & | operator= (const AnyBase &other) |
| | Copy assignment operator (only when Copyable is true).
|
| template<typename T> |
| T | take () |
| | Move the stored value out.
|
| const std::type_info * | typeInfo () const |
| | Type info of the stored value.
|
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
class Acts::AnyBase< SbSize, Copyable, Base >
Small opaque type-erased type with configurable small buffer optimization.
- Template Parameters
-
| SbSize | Size of the internal buffer for small buffer optimization |
| Copyable | If true, stored types must be copyable and AnyBase is copyable. If false, move-only types are allowed and AnyBase is move-only (copy constructor and copy assignment are deleted). |
- Note
- Type requirements when Copyable is true:
- All stored types must be copy constructible and copy assignable.
- Types stored locally (sizeof(T) <= SbSize) must also be move constructible and move assignable because local moves use move operations when not trivially movable (trivial moves fall back to buffer copies).
- Types stored on the heap (sizeof(T) > SbSize) are moved by stealing the pointer, so no move operations are required in that case.
-
Type requirements when Copyable is false:
- All stored types must be move constructible.
- Types stored locally must also be move assignable.
- Heap-allocated types only need move constructible (pointer steal).
-
In summary:
- Local storage: values live inside the internal buffer; moves may invoke move operations or buffer copies; copies use copy operations or buffer copies when trivial.
- Heap storage: values are allocated on the heap; moves transfer ownership of the pointer; copies allocate and copy-construct the pointee.
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename T, typename... Args>
requires (isStorable<std::decay_t<T>>())
| Acts::AnyBase< SbSize, Copyable, Base >::AnyBase |
( |
std::in_place_type_t< T > | , |
|
|
Args &&... | args ) |
|
explicit |
Construct with in-place type construction.
- Template Parameters
-
| T | Type to construct |
| Args | Constructor argument types |
- Parameters
-
| args | Arguments to forward to T's constructor |
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
Get a pointer to the stored value as Base*, regardless of its concrete type.
Only available when Base is not void.
- Returns
- Pointer to the stored value upcast to
Base*, or nullptr if empty
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
| const B * Acts::AnyBase< SbSize, Copyable, Base >::asBase |
( |
| ) |
const |
Get a const pointer to the stored value as Base*.
Only available when Base is not void.
- Returns
- Const pointer to the stored value upcast to
Base*, or nullptr if empty
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename T, typename... Args>
requires (isStorable<std::decay_t<T>>())
| T & Acts::AnyBase< SbSize, Copyable, Base >::emplace |
( |
Args &&... | args | ) |
|
Construct a new value in place, destroying any existing value.
- Template Parameters
-
| T | Type to construct |
| Args | Constructor argument types |
- Parameters
-
| args | Arguments to forward to T's constructor |
- Returns
- Reference to the newly constructed value
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
Dereference to the stored value as Base&.
Only available when Base is not void.
- Returns
- Reference to the stored value upcast to
Base&
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
| const B & Acts::AnyBase< SbSize, Copyable, Base >::operator* |
( |
| ) |
const |
Dereference to the stored value as const Base&.
Only available when Base is not void.
- Returns
- Const reference to the stored value upcast to
Base&
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
Member access on the stored value as Base*.
Only available when Base is not void.
- Returns
- Pointer to the stored value upcast to
Base*
template<std::size_t SbSize, bool Copyable = true, typename Base = void>
template<typename B = Base>
requires (!std::is_void_v<B>)
| const B * Acts::AnyBase< SbSize, Copyable, Base >::operator-> |
( |
| ) |
const |
Member access on the stored value as const Base*.
Only available when Base is not void.
- Returns
- Const pointer to the stored value upcast to
Base*