Any++
Loading...
Searching...
No Matches
anyxx::dispatch< R(Args...)> Class Template Reference

Open dispatch method. Solves the expression problem. More...

#include <anyxx.hpp>

Public Types

enum class  kind { single , multiple }
using erased_function_t
using dispatch_matrix_t = dispatch_matrix<erased_function_t, Args...>::type
using default_ = typename dispatch_function_types<R, Args...>::default_type

Public Member Functions

template<typename... Classes>
auto define (auto f)
 Register a dispatch target for the model provided in the type parameter.
template<typename... ActualArgs>
auto operator() (ActualArgs &&... actual_args) const
 Invoke the dispatch.
auto & get_dispatch_default_hook ()

Public Attributes

dispatch_matrix_t dispatch_matrix_
default_::function_t dispatch_default_hook_
default_::function_t::connection default_connection_
dispatch_access< dispatch_kind, 0, Args... > dispatch_access_

Static Public Attributes

static constexpr std::size_t dimension_count
static const constexpr kind dispatch_kind

Detailed Description

template<typename R, typename... Args>
class anyxx::dispatch< R(Args...)>

Open dispatch method. Solves the expression problem.

Template Parameters
RThe return type.
ArgsThe parameter types. The signature of the dispatch is R(Args...).

The open dispatch is managed via a singleton object of this class.

To declare and define a singleton, use the ANY_SINGLETON and ANY_SINGLETON_DECLARE macros.

Each trait of the any tagged as virtual must have open dispatch enabled. To enable open dispatch, declare a struct named 'trait_name'_has_open_dispatch.

struct node_has_open_dispatch {};
ANY(node<>, , )
// open dispatch evaluate, returns int, dispatched via an any_node;
dispatch<int(virtual_<any_node<>>)> evaluate;
Open dispatch method. Solves the expression problem. See dispatch<R(Args...)> for details.
Definition anyxx.hpp:3904
#define ANY(n, l,...)
Simple ANY macro.
Definition anyxx.hpp:884
A tag to indicate that the corresponding function parameter is an any used for dispatch.
Definition anyxx.hpp:3738

Examples are listed here: dispatch

Member Typedef Documentation

◆ erased_function_t

template<typename R, typename... Args>
using anyxx::dispatch< R(Args...)>::erased_function_t
Initial value:
typename translate_erased_function<R, Args...>::type

Member Function Documentation

◆ define()

template<typename R, typename... Args>
template<typename... Classes>
auto anyxx::dispatch< R(Args...)>::define ( auto f)
inline

Register a dispatch target for the model provided in the type parameter.

Template Parameters
ClassesThe models for which the dispatch target is registered.
Parameters
fThe dispatch target.
Returns
Dummy value, useful for initializing an auto unnamed variable at (static) namespace scope.

◆ operator()()

template<typename R, typename... Args>
template<typename... ActualArgs>
auto anyxx::dispatch< R(Args...)>::operator() ( ActualArgs &&... actual_args) const
inline

Invoke the dispatch.

Template Parameters
ActualArgsThe deduced argument types for the dispatch call.
Parameters
actual_argsArguments fulfilling the signature of this dispatch.
Returns
The result of the dispatched function call.

The called function is determined by the any objects marked with virtual_ in the class instantiation.

Member Data Documentation

◆ default_connection_

template<typename R, typename... Args>
default_::function_t::connection anyxx::dispatch< R(Args...)>::default_connection_
Initial value:
=
dispatch_default_hook_.insert(default_::function())

◆ dimension_count

template<typename R, typename... Args>
std::size_t anyxx::dispatch< R(Args...)>::dimension_count
staticconstexpr
Initial value:
=
dispatch_dimension_count<0, Args...>

◆ dispatch_kind

template<typename R, typename... Args>
const constexpr kind anyxx::dispatch< R(Args...)>::dispatch_kind
staticconstexpr
Initial value:
=
(dimension_count > 1) ? kind::multiple : kind::single

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