kblib 0.2.3
General utilities library for modern C++
kblib::poly_obj_traits< Obj, CType > Struct Template Reference

poly_obj_traits is a traits class template which abstracts the allowed operations on a polymorphic type hierarchy. Any operation allowed by the traits must be usable for the entire hierarchy, not just the base class. More...

#include <kblib/poly_obj.h>

Public Types

using copy_t = default_copy< Obj, copyable >
 Implements type erasure for copy construction. More...
 
using move_t = default_move< Obj, movable, nothrow_movable, copyable >
 Implements type erasure for move construction. More...
 
using destroy_t = default_destroy< Obj >
 Implements type erasure for destruction. The default implementation requires and always uses virtual dispatch for destruction. More...
 

Static Public Attributes

static constexpr std::size_t default_capacity = detail_poly::extract_derived_size<Obj>::value
 The default capacity to use if not overridden. More...
 
static constexpr std::size_t alignment = std::max(alignof(Obj), alignof(std::max_align_t))
 How much to align the storage by. More...
 
static constexpr bool copyable = detail_poly::copyable(CType)
 If the object is copy constructible. More...
 
static constexpr bool movable = detail_poly::movable(CType)
 If the object is move constructible. More...
 
static constexpr bool nothrow_movable = detail_poly::nothrow_movable(CType)
 If the object is nothrow move constructible. More...
 

Detailed Description

template<typename Obj, construct_type CType = detail_poly::construct_traits<Obj>>
struct kblib::poly_obj_traits< Obj, CType >

poly_obj_traits is a traits class template which abstracts the allowed operations on a polymorphic type hierarchy. Any operation allowed by the traits must be usable for the entire hierarchy, not just the base class.

Users of poly_obj may provide explicit specializations of this type, as long as they satisfy all the requirements listed here. Alternatively, users may write their own traits types, subject to the same restrictions.

Definition at line 374 of file poly_obj.h.

Member Typedef Documentation

◆ copy_t

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
using kblib::poly_obj_traits< Obj, CType >::copy_t = default_copy<Obj, copyable>

Implements type erasure for copy construction.

Must be assignable. If copying is enabled, copy_t must have:

  • a nothrow default constructor.
  • a nothrow constructor template taking a single parameter of type T* (always nullptr) that produces a copy constructor for type T.
  • a member function 'copy' which performs the actual copying.
See also
kblib::default_copy

Definition at line 417 of file poly_obj.h.

◆ destroy_t

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
using kblib::poly_obj_traits< Obj, CType >::destroy_t = default_destroy<Obj>

Implements type erasure for destruction. The default implementation requires and always uses virtual dispatch for destruction.

Must be assignable. Must have:

  • a nothrow default constructor.
  • a nothrow constructor template taking a single parameter of type T* (always nullptr) that produces a destroyer for type T.
  • a member function 'destroy' which performs the actual destruction.
See also
kblib::default_destroy

Definition at line 447 of file poly_obj.h.

◆ move_t

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
using kblib::poly_obj_traits< Obj, CType >::move_t = default_move<Obj, movable, nothrow_movable, copyable>

Implements type erasure for move construction.

Must be assignable. If moving is enabled, move_t must have:

  • a nothrow default constructor.
  • a nothrow constructor template taking a single parameter of type T* (always nullptr) that produces a move constructor for type T.
  • a member function 'move' which performs the actual moving.
Note
Move may fall back on copy.
See also
kblib::default_move

Definition at line 432 of file poly_obj.h.

Member Data Documentation

◆ alignment

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
constexpr std::size_t kblib::poly_obj_traits< Obj, CType >::alignment = std::max(alignof(Obj), alignof(std::max_align_t))
staticconstexpr

How much to align the storage by.

Definition at line 388 of file poly_obj.h.

◆ copyable

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
constexpr bool kblib::poly_obj_traits< Obj, CType >::copyable = detail_poly::copyable(CType)
staticconstexpr

If the object is copy constructible.

Definition at line 394 of file poly_obj.h.

◆ default_capacity

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
constexpr std::size_t kblib::poly_obj_traits< Obj, CType >::default_capacity = detail_poly::extract_derived_size<Obj>::value
staticconstexpr

The default capacity to use if not overridden.

The default implementation uses Obj::max_derived_size if it exists, or sizeof(Obj) otherwise.

Definition at line 382 of file poly_obj.h.

◆ movable

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
constexpr bool kblib::poly_obj_traits< Obj, CType >::movable = detail_poly::movable(CType)
staticconstexpr

If the object is move constructible.

Definition at line 399 of file poly_obj.h.

◆ nothrow_movable

template<typename Obj , construct_type CType = detail_poly::construct_traits<Obj>>
constexpr bool kblib::poly_obj_traits< Obj, CType >::nothrow_movable = detail_poly::nothrow_movable(CType)
staticconstexpr

If the object is nothrow move constructible.

Definition at line 403 of file poly_obj.h.


The documentation for this struct was generated from the following file: