kblib 0.2.3
General utilities library for modern C++
kblib::poly_obj< Obj, Capacity, Traits > Class Template Reference

Inline polymorphic object. Generally mimics the interfaces of std::optional and std::variant. More...

#include <kblib/poly_obj.h>

Inheritance diagram for kblib::poly_obj< Obj, Capacity, Traits >:
Collaboration diagram for kblib::poly_obj< Obj, Capacity, Traits >:

Public Types

using base_type = Obj
 
using traits_type = Traits
 

Static Public Attributes

static constexpr std::size_t capacity = Capacity > 0 ? Capacity : Traits::default_capacity
 Equal to Capacity if specified, else Traits::default_capacity. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T , typename D = T, std::size_t Capacity = sizeof(D), typename Traits = poly_obj_traits<T>, typename... Args>
auto make_poly_obj (Args &&... args, std::nullptr_t=poly_warn_if<(Capacity !=sizeof(D) and Capacity > Traits::default_capacity)>()) -> poly_obj< T, std::max(Capacity, Traits::default_capacity), Traits >
 A convenience factory for making poly_objs. More...
 

Object Access

These functions allow access to the contained value.

auto operator* () &noexcept -> Obj &
 Returns a reference to the contained object. More...
 
auto operator* () const &noexcept -> const Obj &
 Returns a reference to the contained object. More...
 
auto operator* () &&noexcept(Traits::nothrow_movable) -> Obj &&
 Returns a reference to the contained object. More...
 
auto operator* () const &&noexcept(Traits::nothrow_movable) -> const Obj &&
 Returns a reference to the contained object. More...
 
auto get () &noexcept -> Obj *
 Returns a pointer to the contained object. More...
 
auto get () const &noexcept -> const Obj *
 Returns a pointer to the contained object. More...
 
auto operator-> () &noexcept -> Obj *
 Returns a pointer to the contained object. More...
 
auto operator-> () const &noexcept -> const Obj *
 Returns a pointer to the contained object. More...
 
template<typename... Args>
auto operator() (Args &&... args) noexcept(is_nothrow_invocable< Obj &, Args &&... >::value) -> fakestd::invoke_result_t< Obj &, Args &&... >
 Invokes the contained function object, if Obj is a callable type. More...
 
template<typename... Args>
auto operator() (Args &&... args) const noexcept(is_nothrow_invocable< const Obj &, Args &&... >::value) -> fakestd::invoke_result_t< const Obj &, Args &&... >
 Invokes the contained function object, if Obj is a callable type. More...
 
template<typename member_type >
enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > & operator->* (member_type Obj::*member) &noexcept
 Access a member variable using a pointer to member. More...
 
template<typename member_type >
const enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > & operator->* (member_type Obj::*member) const &noexcept
 Access a member variable using a pointer to member. More...
 
template<typename member_type >
enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > && operator->* (member_type Obj::*member) &&noexcept
 Access a member variable using a pointer to member. More...
 
template<typename member_type >
const enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > && operator->* (member_type Obj::*member) const &&noexcept
 Access a member variable using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...)) &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const) &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const) const &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const) &&noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) &) &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const &) &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const &) const &noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) &&) &&noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const &) &&noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...)) &&noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const &&) &&noexcept
 Call a member function using a pointer to member. More...
 
template<typename member_type , typename... Args>
auto operator->* (member_type(Obj::*member)(Args...) const &&) const &&noexcept
 Call a member function using a pointer to member. More...
 

Construction

constexpr poly_obj ()=default
 The default constructor does not construct any contained object. More...
 
constexpr poly_obj (std::nullptr_t) noexcept
 Explicitly do not construct an object. More...
 
constexpr poly_obj (const Obj &obj)
 Copy-constructs the contained object from obj. More...
 
constexpr poly_obj (Obj &&obj) noexcept(Traits::nothrow_movable)
 Move-constructs the contained object from obj. More...
 
template<typename... Args, typename std::enable_if_t< std::is_constructible< Obj, Args... >::value, int > = 0>
constexpr poly_obj (fakestd::in_place_t, Args &&... args) noexcept(std::is_nothrow_constructible< Obj, Args &&... >::value)
 Constructs the contained object in-place without copying or moving. More...
 
template<typename... Args, typename std::enable_if_t< std::is_constructible< Obj, Args... >::value, int > = 0>
constexpr poly_obj (kblib::in_place_agg_t, Args &&... args) noexcept(std::is_nothrow_constructible< Obj, Args &&... >::value)
 Constructs the contained object in-place without copying or moving. More...
 
template<typename U , typename... Args>
static auto make (Args &&... args) noexcept(std::is_nothrow_constructible< U, Args &&... >::value) -> poly_obj
 Constructs a poly_obj containing an object of derived type. More...
 
template<typename U , typename... Args>
static auto make_aggregate (Args &&... args) noexcept(std::is_nothrow_constructible< U, Args &&... >::value) -> poly_obj
 Constructs a poly_obj containing an object of derived type. More...
 

Copy/move operators

constexpr poly_obj (const poly_obj &other)
 Constructs a copy of other. More...
 
constexpr poly_obj (poly_obj &&other) noexcept(Traits::nothrow_movable)
 Moves the contained object of other into this. Note that the moved- from poly_obj is not cleared; instead, its contained value is moved from. More...
 
auto operator= (const poly_obj &other) &-> poly_obj &
 Destroys the contained object, if any, and then copies other as in the copy constructor. More...
 
auto operator= (poly_obj &&other) &noexcept(Traits::nothrow_movable) -> poly_obj &
 Destroys the contained object, if any, and then moves from other as in the move constructor. More...
 

Validity

Check if the poly_obj contains a value.

auto has_value () const &noexcept -> bool
 
 operator bool () const &noexcept
 

Destruction

auto clear () noexcept -> void
 Empties the poly_obj, reverting to a default-constructed state. More...
 
 ~poly_obj () noexcept
 

Detailed Description

template<typename Obj, std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
class kblib::poly_obj< Obj, Capacity, Traits >

Inline polymorphic object. Generally mimics the interfaces of std::optional and std::variant.

Provides dynamic polymorphism without dynamic allocation. By default, it is copy and move constructible if and only if Obj is. The storage capacity can be overloaded in case derived objects are larger than the base (this is expected to be commonplace).

Template Parameters
ObjThe base class type which the poly_obj will store. Must have a virtual destructor unless a custom traits class is provided.
CapacityThe inline capacity allocated for the contained object. May be set larger than sizeof(Obj) to account for larger derived classes. A value of 0 indicates that the traits type should be used to obtain the capacity.
TraitsA type providing member types and constants defining the allowed operations on the object type.
See also
kblib::poly_obj_traits

Definition at line 478 of file poly_obj.h.

Member Typedef Documentation

◆ base_type

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
using kblib::poly_obj< Obj, Capacity, Traits >::base_type = Obj

Definition at line 499 of file poly_obj.h.

◆ traits_type

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
using kblib::poly_obj< Obj, Capacity, Traits >::traits_type = Traits

Definition at line 500 of file poly_obj.h.

Constructor & Destructor Documentation

◆ poly_obj() [1/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( )
constexprdefault

The default constructor does not construct any contained object.

◆ poly_obj() [2/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( std::nullptr_t  )
inlineconstexprnoexcept

Explicitly do not construct an object.

Definition at line 513 of file poly_obj.h.

◆ poly_obj() [3/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( const Obj &  obj)
inlineconstexpr

Copy-constructs the contained object from obj.

This function can only be called if Obj is copy-constructible.

Parameters
objThe object to copy.

Definition at line 522 of file poly_obj.h.

◆ poly_obj() [4/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( Obj &&  obj)
inlineconstexprnoexcept

Move-constructs the contained object from obj.

This function can only be called if Obj is move-constructible.

Parameters
objThe object to move from.

Definition at line 531 of file poly_obj.h.

◆ poly_obj() [5/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename... Args, typename std::enable_if_t< std::is_constructible< Obj, Args... >::value, int > = 0>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( fakestd::in_place_t  ,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Constructs the contained object in-place without copying or moving.

Parameters
argsArguments to be passed to the constructor of Obj.
See also
kblib::fakestd::in_place

Definition at line 543 of file poly_obj.h.

◆ poly_obj() [6/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename... Args, typename std::enable_if_t< std::is_constructible< Obj, Args... >::value, int > = 0>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( kblib::in_place_agg_t  ,
Args &&...  args 
)
inlineexplicitconstexprnoexcept

Constructs the contained object in-place without copying or moving.

Parameters
argsArguments to be passed to the constructor of Obj.
See also
kblib::in_place_agg

Definition at line 557 of file poly_obj.h.

◆ poly_obj() [7/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( const poly_obj< Obj, Capacity, Traits > &  other)
inlineconstexpr

Constructs a copy of other.

This function can only be called if Traits::copyable is true.

Parameters
otherA poly_obj to copy from.

Definition at line 638 of file poly_obj.h.

◆ poly_obj() [8/8]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr kblib::poly_obj< Obj, Capacity, Traits >::poly_obj ( poly_obj< Obj, Capacity, Traits > &&  other)
inlineconstexprnoexcept

Moves the contained object of other into this. Note that the moved- from poly_obj is not cleared; instead, its contained value is moved from.

This function can only be called if Traits::movable is true.

Parameters
otherA poly_obj to move from.

Definition at line 653 of file poly_obj.h.

◆ ~poly_obj()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
kblib::poly_obj< Obj, Capacity, Traits >::~poly_obj ( )
inlinenoexcept

Definition at line 732 of file poly_obj.h.

Member Function Documentation

◆ clear()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::clear ( ) -> void
inlinenoexcept

Empties the poly_obj, reverting to a default-constructed state.

Definition at line 724 of file poly_obj.h.

◆ get() [1/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::get ( ) & -> Obj*
inlinenoexcept

Returns a pointer to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness of *this carries over to the contained object, because it is contained inside of *this.

Returns
Obj* A pointer to the contained object.

Definition at line 809 of file poly_obj.h.

◆ get() [2/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::get ( ) const & -> const Obj*
inlinenoexcept

Returns a pointer to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness of *this carries over to the contained object, because it is contained inside of *this.

Returns
const Obj* A pointer to the contained object.

Definition at line 819 of file poly_obj.h.

◆ has_value()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::has_value ( ) const & -> bool
inlinenoexcept

Definition at line 712 of file poly_obj.h.

◆ make()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename U , typename... Args>
static auto kblib::poly_obj< Obj, Capacity, Traits >::make ( Args &&...  args) -> poly_obj
inlinestaticnoexcept

Constructs a poly_obj containing an object of derived type.

This function provides the polymorphism of poly_obj.

sizeof(U) must be less than or equal to capacity, and must be copy-constructible and move-constructible if Traits is.

Template Parameters
UA type publically derived from Obj.
Parameters
argsArguments to pass to the constructor of U.
Returns
poly_obj A poly_obj<Obj> containing an object of type U.

Definition at line 575 of file poly_obj.h.

◆ make_aggregate()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename U , typename... Args>
static auto kblib::poly_obj< Obj, Capacity, Traits >::make_aggregate ( Args &&...  args) -> poly_obj
inlinestaticnoexcept

Constructs a poly_obj containing an object of derived type.

This function provides the polymorphism of poly_obj.

sizeof(U) must be less than or equal to capacity, and must be copy-constructible and move-constructible if Traits is.

Template Parameters
UA type publically derived from Obj.
Parameters
argsArguments to pass to the constructor of U.
Returns
poly_obj A poly_obj<Obj> containing an object of type U.

Definition at line 607 of file poly_obj.h.

◆ operator bool()

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
kblib::poly_obj< Obj, Capacity, Traits >::operator bool ( ) const &
inlineexplicitnoexcept

Definition at line 714 of file poly_obj.h.

◆ operator()() [1/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator() ( Args &&...  args) const -> fakestd::invoke_result_t<const Obj&, Args&&...>
inlinenoexcept

Invokes the contained function object, if Obj is a callable type.

Invokes the contained object, if it exists. If it does not exist, the behavior is undefined.

Parameters
argsThe arguments to forward to the function.
Returns
invoke_result_t<const Obj&, Args&&...> The return value of the function.

Definition at line 871 of file poly_obj.h.

◆ operator()() [2/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator() ( Args &&...  args) -> fakestd::invoke_result_t<Obj&, Args&&...>
inlinenoexcept

Invokes the contained function object, if Obj is a callable type.

Invokes the contained object, if it exists. If it does not exist, the behavior is undefined.

Parameters
argsThe arguments to forward to the function.
Returns
invoke_result_t<Obj&, Args&&...> The return value of the function.

Definition at line 855 of file poly_obj.h.

◆ operator*() [1/4]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator* ( ) && -> Obj&&
inlinenoexcept

Returns a reference to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness and reference qualification of *this carries over to the contained object, because it is contained inside of *this.

Returns
Obj&& An rvalue reference to the contained object.

Definition at line 778 of file poly_obj.h.

◆ operator*() [2/4]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator* ( ) & -> Obj&
inlinenoexcept

Returns a reference to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness and reference qualification of *this carries over to the contained object, because it is contained inside of *this.

Returns
Obj& A reference to the contained object.

Definition at line 754 of file poly_obj.h.

◆ operator*() [3/4]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator* ( ) const && -> const Obj&&
inlinenoexcept

Returns a reference to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness and reference qualification of *this carries over to the contained object, because it is contained inside of *this.

This particular overload is not expected to be very useful, but it is provided for completeness.

Returns
const Obj&& A const rvalue reference to the contained object.

Definition at line 795 of file poly_obj.h.

◆ operator*() [4/4]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator* ( ) const & -> const Obj&
inlinenoexcept

Returns a reference to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness and reference qualification of *this carries over to the contained object, because it is contained inside of *this.

Returns
const Obj& A reference to the contained object.

Definition at line 765 of file poly_obj.h.

◆ operator->() [1/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator-> ( ) & -> Obj*
inlinenoexcept

Returns a pointer to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness of *this carries over to the contained object, because it is contained inside of *this.

Returns
Obj* A pointer to the contained object.

Definition at line 830 of file poly_obj.h.

◆ operator->() [2/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator-> ( ) const & -> const Obj*
inlinenoexcept

Returns a pointer to the contained object.

Returns a reference to the contained object, if it exists. If it does not exist, the behavior is undefined. Notably, the constness of *this carries over to the contained object, because it is contained inside of *this.

Returns
const Obj* A pointer to the contained object.

Definition at line 840 of file poly_obj.h.

◆ operator->*() [1/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type >
enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > && kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type Obj::*  member) &&
inlinenoexcept

Access a member variable using a pointer to member.

Definition at line 904 of file poly_obj.h.

◆ operator->*() [2/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type >
enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > & kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type Obj::*  member) &
inlinenoexcept

Access a member variable using a pointer to member.

Definition at line 883 of file poly_obj.h.

◆ operator->*() [3/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type >
const enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > && kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type Obj::*  member) const &&
inlinenoexcept

Access a member variable using a pointer to member.

Definition at line 915 of file poly_obj.h.

◆ operator->*() [4/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type >
const enable_if_t< not std::is_member_function_pointer< member_type Obj::* >::value, member_type > & kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type Obj::*  member) const &
inlinenoexcept

Access a member variable using a pointer to member.

Definition at line 894 of file poly_obj.h.

◆ operator->*() [5/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) member &&  ) &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
&& on &&

Definition at line 1008 of file poly_obj.h.

◆ operator->*() [6/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) member &  ) &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
& on &

Definition at line 972 of file poly_obj.h.

◆ operator->*() [7/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const member &&  ) &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const&& on &&

Definition at line 1044 of file poly_obj.h.

◆ operator->*() [8/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const member &&  ) const &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const&& on const&&

Definition at line 1056 of file poly_obj.h.

◆ operator->*() [9/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const member &  ) &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const& on &&

Definition at line 1020 of file poly_obj.h.

◆ operator->*() [10/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const member &  ) &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const& on &

Definition at line 984 of file poly_obj.h.

◆ operator->*() [11/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const member &  ) const &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const& on const&

Definition at line 996 of file poly_obj.h.

◆ operator->*() [12/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const  member) &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const on &&

Definition at line 960 of file poly_obj.h.

◆ operator->*() [13/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const  member) &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const on &

Definition at line 936 of file poly_obj.h.

◆ operator->*() [14/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...) const  member) const &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
const on const&

Definition at line 948 of file poly_obj.h.

◆ operator->*() [15/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...)  member) &&
inlinenoexcept

Call a member function using a pointer to member.

Remarks
Unqualified on &&

Definition at line 1032 of file poly_obj.h.

◆ operator->*() [16/16]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
template<typename member_type , typename... Args>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator->* ( member_type(Obj::*)(Args...)  member) &
inlinenoexcept

Call a member function using a pointer to member.

Remarks
unqualified on &

Definition at line 924 of file poly_obj.h.

◆ operator=() [1/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator= ( const poly_obj< Obj, Capacity, Traits > &  other) & -> poly_obj&
inline

Destroys the contained object, if any, and then copies other as in the copy constructor.

Parameters
otherA poly_obj to copy from.
Returns
poly_obj& *this.

@exceptions In the event that the constructor of Obj throws, the poly_obj is cleared and the exception rethrown.

Definition at line 671 of file poly_obj.h.

◆ operator=() [2/2]

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
auto kblib::poly_obj< Obj, Capacity, Traits >::operator= ( poly_obj< Obj, Capacity, Traits > &&  other) & -> poly_obj&
inlinenoexcept

Destroys the contained object, if any, and then moves from other as in the move constructor.

Parameters
otherA poly_obj to move from.
Returns
poly_obj& *this.

@exceptions In the event that the constructor of Obj throws, the poly_obj is cleared and the exception rethrown.

Definition at line 693 of file poly_obj.h.

Friends And Related Function Documentation

◆ make_poly_obj()

template<typename T , typename D = T, std::size_t Capacity = sizeof(D), typename Traits = poly_obj_traits<T>, typename... Args>
auto make_poly_obj ( Args &&...  args,
std::nullptr_t  = poly_warn_if<(Capacity != sizeof(D)                                   and Capacity > Traits::default_capacity)>() 
) -> poly_obj<T, std::max(Capacity, Traits::default_capacity), Traits>
related

A convenience factory for making poly_objs.

Definition at line 1102 of file poly_obj.h.

Member Data Documentation

◆ capacity

template<typename Obj , std::size_t Capacity = 0, typename Traits = poly_obj_traits<Obj>>
constexpr std::size_t kblib::poly_obj< Obj, Capacity, Traits >::capacity = Capacity > 0 ? Capacity : Traits::default_capacity
staticconstexpr

Equal to Capacity if specified, else Traits::default_capacity.

Definition at line 491 of file poly_obj.h.


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