Any++
Loading...
Searching...
No Matches
anyxx::any< Proxy, Trait > Class Template Reference

The core class template to control dispatch for external polymorphism. More...

#include <anyxx.hpp>

Public Types

using proxy_t = Proxy
using proxy_trait_t = proxy_trait<proxy_t>
using void_t = typename proxy_trait_t::void_t
using v_table_holder_t = v_table_holder<is_dyn<Proxy>, Trait>
using trait_t = Trait
using v_table_t = typename v_table_holder_t::v_table_t
using T = proxy_trait_t::static_dispatch_t
using any_value_t = any<val, Trait>
template<typename Box>
using type_for = any<Box, Trait>

Public Member Functions

template<typename ConstructedWith>
requires constructibile_for<ConstructedWith, Proxy> && (!std::same_as<any, std::decay_t<ConstructedWith>>) && (!is_lifetime_bound<Proxy>)
 explicit (false) any(ConstructedWith &&const ructed_with)
template<typename ConstructedWith>
requires constructibile_for<ConstructedWith, Proxy> && (!std::same_as<any, std::decay_t<ConstructedWith>>) && (is_lifetime_bound<Proxy>)
 explicit (false) any(ConstructedWith &&const ructed_with LIFETIMEBOUND)
template<typename V>
 any (std::in_place_t, V &&v)
template<typename T, typename... Args>
 any (std::in_place_type_t< T >, Args &&... args)
 any (const any &other)
 any (const any &other)
any & operator= (any const &other)
template<is_any Other>
requires (borrowable_from<proxy_t, typename Other::proxy_t, typename Other::v_table_t> && (!is_dyn<Proxy> || std::derived_from<typename Other::v_table_t, v_table_t>))
 explicit (false) any(const Other &other)
template<is_any Other>
requires (borrowable_from<proxy_t, typename Other::proxy_t, typename Other::v_table_t> && (!is_dyn<Proxy> || std::derived_from<typename Other::v_table_t, v_table_t>))
any & operator= (Other const &other)
template<is_proxy OtherErasedData>
 any (OtherErasedData &&proxy, v_table_t *v_table) noexcept
template<is_proxy OtherErasedData>
 any (OtherErasedData &&proxy, v_table_t *v_table) noexcept
template<is_any Other>
requires (moveable_from<proxy_t, typename Other::proxy_t> && (!is_dyn<Proxy> || std::derived_from<typename Other::v_table_t, v_table_t>))
 explicit (false) any(Other &&other) noexcept
template<is_any Other>
requires (moveable_from<proxy_t, typename Other::proxy_t> && (!is_dyn<Proxy> || std::derived_from<typename Other::v_table_t, v_table_t>))
any & operator= (Other &&other) noexcept
 operator bool () const

Static Public Attributes

static constexpr bool dyn = is_dyn<Proxy>

Protected Attributes

proxy_t proxy_ {}

Friends

template<is_any Friend>
auto & get_proxy (Friend const &any)
template<is_any Friend>
auto & get_proxy (Friend &any)
template<is_any Friend>
decltype(auto) move_proxy (Friend &&any)
template<is_any Friend>
auto get_proxy_ptr (Friend const &any)
template<typename Friend>
auto get_v_table (Friend const &any)
template<is_any To, is_any From>
requires ( std::derived_from<typename To::v_table_t, typename From::v_table_t>)
To unchecked_downcast_to (From from)

Detailed Description

template<is_proxy Proxy, typename Trait>
class anyxx::any< Proxy, Trait >

The core class template to control dispatch for external polymorphism.

To control the behavior, any provides two template parameters: Proxy and Trait. Imagine this as a combination of a std::any and several std::functions.

With the Proxy template parameter, you control whether this any behaves like a copying function, a move-only function, a reference function, or if the target object is captured concretely inside of any.

With the Trait template parameter, you specify the member functions of a captured object which can be invoked on this any.

Template Parameters
ProxySpecifies the lifetime of the captured object. Any++ provides using_, cref, mutref, shared, weak, unique, and value. All Proxy classes must conform to the is_proxy concept.
TraitSpecifies the functionality of this any. A class of this type is normally provided via a TRAIT or ANY macro. See there for examples. If the proxy is dynamic (i.e., type erased), the Trait must conform to the has_v_table concept (that means: must provide a v-Table).
Examples
21_Tree_any_borrow_as.cpp, _2d_trait_self.cpp, _2o_trait_simple.cpp, _3_any_range.cpp, and _5_any_template.cpp.

Constructor & Destructor Documentation

◆ any() [1/2]

template<is_proxy Proxy, typename Trait>
template<typename V>
anyxx::any< Proxy, Trait >::any ( std::in_place_t ,
V && v )
inline

Type-erasing constructor. The concrete behavior is controlled by the proxy. The value v will be forwarded to the managed storage.

Template Parameters
VThe type of the object to be forwarded into the managed storage. Usually deduced.
Parameters
std::in_place_tTag to select in-place construction. (On call site, use std::in_place.)
vThe object to be forwarded into the managed storage.

◆ any() [2/2]

template<is_proxy Proxy, typename Trait>
template<typename T, typename... Args>
anyxx::any< Proxy, Trait >::any ( std::in_place_type_t< T > ,
Args &&... args )
inline

Type erasing constructor, the concrete behavior is controled by the proxy

Parameters
std::in_place_type_t<T>Tag to select in-place construction of T
argsThe arguments to construct the object of type T with, will be forwarded.

Member Function Documentation

◆ explicit() [1/2]

template<is_proxy Proxy, typename Trait>
template<typename ConstructedWith>
requires constructibile_for<ConstructedWith, Proxy> && (!std::same_as<any, std::decay_t<ConstructedWith>>) && (is_lifetime_bound<Proxy>)
anyxx::any< Proxy, Trait >::explicit ( false ) const &&
inline

Type-erasing constructor for borrowing proxies. The concrete behavior is controlled by the proxy via its corresponding proxy_trait. See cref, mutref

◆ explicit() [2/2]

template<is_proxy Proxy, typename Trait>
template<typename ConstructedWith>
requires constructibile_for<ConstructedWith, Proxy> && (!std::same_as<any, std::decay_t<ConstructedWith>>) && (!is_lifetime_bound<Proxy>)
anyxx::any< Proxy, Trait >::explicit ( false ) const &&
inline

Type-erasing constructor for lifetime owning proxies. The concrete behavior is controlled by the proxy via its corresponding proxy_trait. See using_, shared, weak, unique, and value.


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