template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
class guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >
Class for polymorphism through type erasure.
Saves the entire vtable, and uses small buffer optimization.
Definition at line 235 of file type-erasure.hpp.
|
| | TypeErased () noexcept(noexcept(allocator_type()) &&noexcept(VTable()))=default |
| | Default constructor.
|
| template<class Alloc> |
| | TypeErased (std::allocator_arg_t, const Alloc &alloc) |
| | Default constructor (allocator aware).
|
| | TypeErased (const TypeErased &other) |
| | Copy constructor.
|
| | TypeErased (const TypeErased &other, const allocator_type &alloc) |
| | Copy constructor (allocator aware).
|
| | TypeErased (std::allocator_arg_t, const allocator_type &alloc, const TypeErased &other) |
| | Copy constructor (allocator aware).
|
| TypeErased & | operator= (const TypeErased &other) |
| | Copy assignment.
|
| | TypeErased (TypeErased &&other) noexcept |
| | Move constructor.
|
| | TypeErased (TypeErased &&other, const allocator_type &alloc) noexcept |
| | Move constructor (allocator aware).
|
| | TypeErased (std::allocator_arg_t, const allocator_type &alloc, TypeErased &&other) noexcept |
| | Move constructor (allocator aware).
|
| TypeErased & | operator= (TypeErased &&other) noexcept |
| | Move assignment.
|
| | ~TypeErased () |
| | Destructor.
|
| template<class T, class Alloc> |
| | TypeErased (std::allocator_arg_t, const Alloc &alloc, T &&d) |
| | Main constructor that type-erases the given argument.
|
| template<class T, class Alloc, class... Args> |
| | TypeErased (std::allocator_arg_t, const Alloc &alloc, std::in_place_type_t< T >, Args &&...args) |
| | Main constructor that type-erases the object constructed from the given argument.
|
| template<class T> |
| | TypeErased (T &&d) |
| | Main constructor that type-erases the given argument.
|
| template<class T, class... Args> |
| | TypeErased (std::in_place_type_t< T >, Args &&...args) |
| | Main constructor that type-erases the object constructed from the given argument.
|
| | operator bool () const noexcept |
| | Check if this wrapper wraps an object.
|
| bool | owns_referenced_object () const noexcept |
| | Check if this wrapper owns the storage of the wrapped object, or whether it simply stores a reference to an object that was allocated elsewhere.
|
| bool | referenced_object_is_const () const noexcept |
| | Check if the wrapped object is const.
|
| allocator_type | get_allocator () const noexcept |
| | Get a copy of the allocator.
|
| const std::type_info & | type () const noexcept |
| | Query the contained type.
|
| template<class T> |
| T & | as () & |
| | Convert the type-erased object to the given type.
|
| template<class T> |
| T & | as () const & |
| | Convert the type-erased object to the given type.
|
| template<class T> |
| T && | as () && |
| | Convert the type-erased object to the given type.
|
| void * | get_pointer () const |
| | Get a type-erased pointer to the wrapped object.
|
| const void * | get_const_pointer () const |
| | Get a type-erased pointer to the wrapped object.
|
|
| template<class Ret, class T, class Alloc, class... Args> |
| static Ret | make (std::allocator_arg_t tag, const Alloc &alloc, Args &&...args) |
| | Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.
|
| template<class Ret, class T, class... Args> |
| static Ret | make (Args &&...args) |
| | Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.
|
|
| template<class T, class... Args> |
| void | construct_inplace (Args &&...args) |
| | Ensure storage and construct the type-erased object of type T in-place.
|
| template<class Ret, class... FArgs, class... Args> |
| decltype(auto) | call (Ret(*f)(const void *, FArgs...), Args &&...args) const |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
| template<class Ret, class... FArgs, class... Args> |
| decltype(auto) | call (Ret(*f)(void *, FArgs...), Args &&...args) |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
| template<class Ret> |
| decltype(auto) | call (Ret(*f)(const void *)) const |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
| template<class Ret> |
| decltype(auto) | call (Ret(*f)(void *)) |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
| template<class Ret> |
| decltype(auto) | call (Ret(*f)(const void *, const VTable &)) const |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
| template<class Ret> |
| decltype(auto) | call (Ret(*f)(void *, const VTable &)) |
| | Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
|
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class T, class Alloc>
| guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::TypeErased |
( |
std::allocator_arg_t | , |
|
|
const Alloc & | alloc, |
|
|
T && | d ) |
|
inlineexplicit |
Main constructor that type-erases the given argument.
Definition at line 436 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class T, class Alloc, class... Args>
| guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::TypeErased |
( |
std::allocator_arg_t | , |
|
|
const Alloc & | alloc, |
|
|
std::in_place_type_t< T > | , |
|
|
Args &&... | args ) |
|
inlineexplicit |
Main constructor that type-erases the object constructed from the given argument.
Definition at line 443 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class T>
Main constructor that type-erases the given argument.
Requirement prevents this constructor from taking precedence over the copy and move constructors.
Definition at line 453 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class T, class... Args>
| guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::TypeErased |
( |
std::in_place_type_t< T > | , |
|
|
Args &&... | args ) |
|
inlineexplicit |
Main constructor that type-erases the object constructed from the given argument.
Definition at line 459 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret, class T, class Alloc, class... Args>
| Ret guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::make |
( |
std::allocator_arg_t | tag, |
|
|
const Alloc & | alloc, |
|
|
Args &&... | args ) |
|
inlinestatic |
Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.
Definition at line 467 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret, class T, class... Args>
Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.
Definition at line 477 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
Check if this wrapper wraps an object.
False for default-constructed objects.
Definition at line 484 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
| bool guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::owns_referenced_object |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Check if this wrapper owns the storage of the wrapped object, or whether it simply stores a reference to an object that was allocated elsewhere.
Definition at line 489 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
Ensure that storage is available, either by using the small buffer if it is large enough, or by calling the allocator.
Returns a RAII wrapper that deallocates the storage unless released.
Definition at line 572 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
Destroy the type-erased object (if not empty), and deallocate the memory if necessary.
Definition at line 596 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class T, class... Args>
| void guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::construct_inplace |
( |
Args &&... | args | ) |
|
|
inlineprotected |
Ensure storage and construct the type-erased object of type T in-place.
Definition at line 631 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret, class... FArgs, class... Args>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(const void *, FArgs...), |
|
|
Args &&... | args ) const |
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 662 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret, class... FArgs, class... Args>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(void *, FArgs...), |
|
|
Args &&... | args ) |
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 674 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(const void *) | ) |
const |
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 688 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(void *) | ) |
|
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 695 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(const void *, const VTable &) | ) |
const |
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 704 of file type-erasure.hpp.
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
template<class Ret>
| decltype(auto) guanaqo::TypeErased< VTable, Allocator, SmallBufferSize >::call |
( |
Ret(* | f )(void *, const VTable &) | ) |
|
|
inlineprotected |
Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
Definition at line 712 of file type-erasure.hpp.