Clementine
|
Static polymorphism made simple and within everyone's reach. More...
#include <entt.hpp>
Public Types | |
using | concept_type = typename Concept::template type< poly_base< poly< Concept > >> |
Concept type. | |
Public Member Functions | |
poly () ENTT_NOEXCEPT | |
Default constructor. | |
template<typename Type , typename... Args> | |
poly (std::in_place_type_t< Type >, Args &&... args) | |
Constructs a poly by directly initializing the new object. More... | |
template<typename Type > | |
poly (std::reference_wrapper< Type > value) | |
Constructs a poly that holds an unmanaged object. More... | |
template<typename Type , typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, poly>>> | |
poly (Type &&value) ENTT_NOEXCEPT | |
Constructs a poly from a given value. More... | |
poly (const poly &other)=default | |
Copy constructor. More... | |
poly (poly &&other) ENTT_NOEXCEPT | |
Move constructor. More... | |
poly & | operator= (poly other) |
Assignment operator. More... | |
type_info | type () const ENTT_NOEXCEPT |
Returns the type of the contained object. More... | |
const void * | data () const ENTT_NOEXCEPT |
Returns an opaque pointer to the contained instance. More... | |
void * | data () ENTT_NOEXCEPT |
Returns an opaque pointer to the contained instance. More... | |
template<typename Type , typename... Args> | |
void | emplace (Args &&... args) |
Replaces the contained object by creating a new instance directly. More... | |
operator bool () const ENTT_NOEXCEPT | |
Returns false if a poly is empty, true otherwise. More... | |
concept_type * | operator-> () ENTT_NOEXCEPT |
Returns a pointer to the underlying concept. More... | |
const concept_type * | operator-> () const ENTT_NOEXCEPT |
Returns a pointer to the underlying concept. More... | |
Friends | |
struct | poly_base< poly< Concept > > |
A poly base is allowed to snoop into a poly object. | |
void | swap (poly &lhs, poly &rhs) |
Swaps two poly objects. More... | |
poly | as_ref (poly &other) ENTT_NOEXCEPT |
Aliasing constructor. More... | |
poly | as_ref (const poly &other) ENTT_NOEXCEPT |
Aliasing constructor. More... | |
Static polymorphism made simple and within everyone's reach.
Static polymorphism is a very powerful tool in C++, albeit sometimes cumbersome to obtain.
This class aims to make it simple and easy to use.
poly
class template also works with unmanaged objects.Concept | Concept descriptor. |
|
inlineexplicit |
Constructs a poly by directly initializing the new object.
Type | Type of object to use to initialize the poly. |
Args | Types of arguments to use to construct the new instance. |
args | Parameters to use to construct the instance. |
|
inline |
Constructs a poly that holds an unmanaged object.
Type | Type of object to use to initialize the poly. |
value | An instance of an object to use to initialize the poly. |
|
inline |
Constructs a poly from a given value.
Type | Type of object to use to initialize the poly. |
value | An instance of an object to use to initialize the poly. |
|
default |
Copy constructor.
other | The instance to copy from. |
|
inline |
Move constructor.
other | The instance to move from. |
|
inline |
Returns an opaque pointer to the contained instance.
|
inline |
Returns an opaque pointer to the contained instance.
|
inline |
Replaces the contained object by creating a new instance directly.
Type | Type of object to use to initialize the poly. |
Args | Types of arguments to use to construct the new instance. |
args | Parameters to use to construct the instance. |
|
inlineexplicit |
Returns false if a poly is empty, true otherwise.
|
inline |
Returns a pointer to the underlying concept.
|
inline |
Returns a pointer to the underlying concept.
|
inline |
Assignment operator.
other | The instance to assign from. |
|
inline |
Returns the type of the contained object.
Aliasing constructor.
other | A reference to an object that isn't necessarily initialized. |
Aliasing constructor.
other | A reference to an object that isn't necessarily initialized. |
Swaps two poly objects.
lhs | A valid poly object. |
rhs | A valid poly object. |