EnTT: entt::basic_poly< Concept, Len, Align > Class Template Reference

EnTT 3.15.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
entt::basic_poly< Concept, Len, Align > Class Template Reference

Static polymorphism made simple and within everyone's reach. More...

`#include <poly.hpp>`

Inheritance diagram for entt::basic_poly< Concept, Len, Align >:
[legend]
Collaboration diagram for entt::basic_poly< Concept, Len, Align >:
[legend]

## Public Types
using | concept_type = typename Concept::template type<poly_base<basic_poly>>
| Concept type.
using | vtable_type = typename poly_vtable<Concept, Len, Align>::type
| Virtual table type.

## Public Member Functions
| basic_poly () noexcept=default
| Default constructor.
template<typename Type, typename... Args>
| basic_poly (std::in_place_type_t< Type >, Args &&...args)
| Constructs a poly by directly initializing the new object.
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, basic_poly>>>
| basic_poly (Type &&value) noexcept
| Constructs a poly from a given value.
const type_info & | type () const noexcept
| Returns the object type if any, `type_id<void>()` otherwise.
const void * | data () const noexcept
| Returns an opaque pointer to the contained instance.
void * | data () noexcept
| Returns an opaque pointer to the contained instance.
template<typename Type, typename... Args>
void | emplace (Args &&...args)
| Replaces the contained object by creating a new instance directly.
void | reset ()
| Destroys contained object.
| operator bool () const noexcept
| Returns false if a poly is empty, true otherwise.
concept_type * | operator-> () noexcept
| Returns a pointer to the underlying concept.
const concept_type * | operator-> () const noexcept
| Returns a pointer to the underlying concept.
basic_poly | as_ref () noexcept
| Aliasing constructor.
basic_poly | as_ref () const noexcept
| Aliasing constructor.

## Friends
struct | poly_base< basic_poly >

## Detailed Description

template<typename Concept, std::size_t Len, std::size_t Align>
class entt::basic_poly< Concept, Len, Align >

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.

Note
  Both deduced and defined static virtual tables are supported.
  Moreover, the `poly` class template also works with unmanaged objects.

Template Parameters

  Concept | Concept descriptor.
  Len | Size of the storage reserved for the small buffer optimization.
  Align | Optional alignment requirement.

Definition at line 193 of file poly.hpp.

## Member Typedef Documentation

## ◆ concept_type

template<typename Concept, std::size_t Len, std::size_t Align>

using entt::basic_poly< Concept, Len, Align >::concept_type = typename Concept::template type<poly_base<basic_poly>>

Concept type.

Definition at line 198 of file poly.hpp.

## ◆ vtable_type

template<typename Concept, std::size_t Len, std::size_t Align>

using entt::basic_poly< Concept, Len, Align >::vtable_type = typename poly_vtable<Concept, Len, Align>::type

Virtual table type.

Definition at line 200 of file poly.hpp.

## Constructor & Destructor Documentation

## ◆ basic_poly() [1/2]

template<typename Concept, std::size_t Len, std::size_t Align>
template<typename Type, typename... Args>

entt::basic_poly< Concept, Len, Align >::basic_poly | ( | std::in_place_type_t< Type > | ,
|  | Args &&... | args )
| inlineexplicit

Constructs a poly by directly initializing the new object.

Template Parameters

  Type | Type of object to use to initialize the poly.
  Args | Types of arguments to use to construct the new instance.

Parameters

  args | Parameters to use to construct the instance.

Definition at line 212 of file poly.hpp.

## ◆ basic_poly() [2/2]

template<typename Concept, std::size_t Len, std::size_t Align>
template<typename Type, typename = std::enable_if_t<!std::is_same_v<std::remove_cv_t<std::remove_reference_t<Type>>, basic_poly>>>

entt::basic_poly< Concept, Len, Align >::basic_poly | ( | Type && | value | ) |
| inlinenoexcept

Constructs a poly from a given value.

Template Parameters

  Type | Type of object to use to initialize the poly.

Parameters

  value | An instance of an object to use to initialize the poly.

Definition at line 222 of file poly.hpp.

## Member Function Documentation

## ◆ as_ref() [1/2]

template<typename Concept, std::size_t Len, std::size_t Align>

basic_poly entt::basic_poly< Concept, Len, Align >::as_ref | ( |  | ) | const
| inlinenodiscardnoexcept

Aliasing constructor.

Returns
  A poly that shares a reference to an unmanaged object.

Definition at line 297 of file poly.hpp.

## ◆ as_ref() [2/2]

template<typename Concept, std::size_t Len, std::size_t Align>

basic_poly entt::basic_poly< Concept, Len, Align >::as_ref | ( |  | ) |
| inlinenodiscardnoexcept

Aliasing constructor.

Returns
  A poly that shares a reference to an unmanaged object.

Definition at line 289 of file poly.hpp.

## ◆ data() [1/2]

template<typename Concept, std::size_t Len, std::size_t Align>

const void * entt::basic_poly< Concept, Len, Align >::data | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

Returns
  An opaque pointer the contained instance, if any.

Definition at line 237 of file poly.hpp.

## ◆ data() [2/2]

template<typename Concept, std::size_t Len, std::size_t Align>

void * entt::basic_poly< Concept, Len, Align >::data | ( |  | ) |
| inlinenodiscardnoexcept

Returns an opaque pointer to the contained instance.

Returns
  An opaque pointer the contained instance, if any.

Definition at line 242 of file poly.hpp.

## ◆ emplace()

template<typename Concept, std::size_t Len, std::size_t Align>
template<typename Type, typename... Args>

void entt::basic_poly< Concept, Len, Align >::emplace | ( | Args &&... | args | ) |
| inline

Replaces the contained object by creating a new instance directly.

Template Parameters

  Type | Type of object to use to initialize the poly.
  Args | Types of arguments to use to construct the new instance.

Parameters

  args | Parameters to use to construct the instance.

Definition at line 253 of file poly.hpp.

## ◆ operator bool()

template<typename Concept, std::size_t Len, std::size_t Align>

entt::basic_poly< Concept, Len, Align >::operator bool | ( |  | ) | const
| inlineexplicitnodiscardnoexcept

Returns false if a poly is empty, true otherwise.

Returns
  False if the poly is empty, true otherwise.

Definition at line 268 of file poly.hpp.

## ◆ operator->() [1/2]

template<typename Concept, std::size_t Len, std::size_t Align>

const concept_type * entt::basic_poly< Concept, Len, Align >::operator-> | ( |  | ) | const
| inlinenodiscardnoexcept

Returns a pointer to the underlying concept.

Returns
  A pointer to the underlying concept.

Definition at line 281 of file poly.hpp.

## ◆ operator->() [2/2]

template<typename Concept, std::size_t Len, std::size_t Align>

concept_type * entt::basic_poly< Concept, Len, Align >::operator-> | ( |  | ) |
| inlinenodiscardnoexcept

Returns a pointer to the underlying concept.

Returns
  A pointer to the underlying concept.

Definition at line 276 of file poly.hpp.

## ◆ reset()

template<typename Concept, std::size_t Len, std::size_t Align>

void entt::basic_poly< Concept, Len, Align >::reset | ( |  | ) |
| inline

Destroys contained object.

Definition at line 259 of file poly.hpp.

## ◆ type()

template<typename Concept, std::size_t Len, std::size_t Align>

const type_info & entt::basic_poly< Concept, Len, Align >::type | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the object type if any, `type_id<void>()` otherwise.

Returns
  The object type if any, `type_id<void>()` otherwise.

Definition at line 229 of file poly.hpp.

## Friends And Related Symbol Documentation

## ◆ poly_base< basic_poly >

template<typename Concept, std::size_t Len, std::size_t Align>

friend struct poly_base< basic_poly >
| friend

Definition at line 151 of file poly.hpp.

The documentation for this class was generated from the following files:

- src/entt/poly/fwd.hpp
- src/entt/poly/poly.hpp