kblib 0.2.3
General utilities library for modern C++
poly_obj.h File Reference

Provides poly_obj, which enables polymorphism to be used without unnecessary per-object dynamic allocations. More...

#include "hash.h"
#include "variant.h"
Include dependency graph for poly_obj.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::detail_poly::construct_conditional< construct_type::none >
 
struct  kblib::detail_poly::construct_conditional< construct_type::copy_only >
 
struct  kblib::detail_poly::construct_conditional< construct_type::move >
 
struct  kblib::detail_poly::construct_conditional< construct_type::both >
 
struct  kblib::detail_poly::construct_conditional< construct_type::throw_move >
 
struct  kblib::detail_poly::construct_conditional< construct_type::both_throw >
 
struct  kblib::detail_poly::erased_hash_t< T, hash >
 
struct  kblib::detail_poly::erased_hash_t< T, void_t< fakestd::invoke_result_t< std::hash< T >, T > > >
 
struct  kblib::detail_poly::kblib_erased_hash_t< T, hash >
 
struct  kblib::detail_poly::kblib_erased_hash_t< T, void_t< fakestd::invoke_result_t< std::hash< T >, T > > >
 
struct  kblib::detail_poly::erased_construct< Traits >
 
struct  kblib::detail_poly::extract_derived_size< T, typename >
 
struct  kblib::detail_poly::extract_derived_size< T, void_if_t<(T::max_derived_size > sizeof(T))> >
 
struct  kblib::default_copy< Obj, copyable >
 Implements type erasure for copy construction. More...
 
struct  kblib::default_copy< Obj, false >
 
struct  kblib::clone_copy< Obj >
 Implements copy construction using a virtual clone method. This type is provided mostly as an example. More...
 
struct  kblib::default_move< Obj, movable, nothrow, copyable >
 Implements type erasure for move construction. More...
 
struct  kblib::default_move< Obj, false, nothrow, false >
 
struct  kblib::default_move< Obj, false, nothrow, true >
 
struct  kblib::default_destroy< Obj >
 Uses the class's virtual destructor. More...
 
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. More...
 
class  kblib::poly_obj< Obj, Capacity, Traits >
 Inline polymorphic object. Generally mimics the interfaces of std::optional and std::variant. More...
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::detail_poly
 Implementation details for poly_obj.
 

Typedefs

template<typename Obj >
using kblib::move_only_traits = poly_obj_traits< Obj, construct_type::move >
 
template<typename Obj >
using kblib::no_move_traits = poly_obj_traits< Obj, construct_type::none >
 

Enumerations

enum class  kblib::construct_type : unsigned {
  kblib::none = 0 , kblib::copy_only = 1 , kblib::move = 2 , kblib::both = 3 ,
  kblib::throw_move = 4 , kblib::both_throw = 5
}
 

Functions

constexpr auto kblib::operator| (construct_type l, construct_type r) noexcept -> construct_type
 
constexpr auto kblib::operator& (construct_type l, construct_type r) noexcept -> construct_type
 
constexpr auto kblib::operator* (construct_type l, bool r) noexcept -> construct_type
 
constexpr auto kblib::detail_poly::copyable (construct_type type) noexcept -> bool
 
constexpr auto kblib::detail_poly::movable (construct_type type) noexcept -> bool
 
constexpr auto kblib::detail_poly::nothrow_movable (construct_type type) noexcept -> bool
 
constexpr auto kblib::detail_poly::make_ctype (bool copyable, bool movable, bool nothrow_movable) -> construct_type
 
template<typename T , typename Traits >
auto kblib::detail_poly::make_ops_t () noexcept -> erased_construct< Traits >
 
template<typename T >
auto kblib::noop (void *, const T *) -> T *
 Does nothing; matches the copy construction signature. More...
 
template<typename T , bool nothrow>
auto kblib::noop (void *, T *) noexcept(nothrow) -> T *
 Does nothing; matches the move construction signature. More...
 
template<bool warn>
constexpr auto kblib::poly_warn_if () -> std::nullptr_t
 
template<>
constexpr auto kblib::poly_warn_if< true > () -> std::nullptr_t
 

Variables

template<typename T >
constexpr construct_type kblib::detail_poly::construct_traits
 

Detailed Description

Provides poly_obj, which enables polymorphism to be used without unnecessary per-object dynamic allocations.

Author
killerbee
Date
2019-2021

Definition in file poly_obj.h.