Any++
Loading...
Searching...
No Matches
TRAIT... and ANY_ macros

Macros to define trait 's and any 's. More...

Macros

#define TRAIT_EX_(n, BASE, l, static_fns, typedefs, decoration)
 TRAIT derived from base with decoration. Macro to define the functional behavior for a any, where the behavior of base is inherited. The decoration are additional functions and typedefs (in brackets).
#define TRAIT_(n, BASE, l)
 TRAIT derived from base.
#define TRAIT(n, fns)
 Macro to define the functional behavior for an any.
#define TRAIT_EX(n, ...)
 TRAIT with decoration.
#define TRAIT_TEMPLATE_EX_(t, n, base, base_template_types, l, static_fns, typedefs, decoration)
 TRAIT template with base and decoration.
#define TRAIT_TEMPLATE_EX(t, n, l, static_fns, typedefs, decoration)
 TRAIT template with decoration.
#define TRAIT_TEMPLATE_(t, n, base, base_template_types, l)
 TRAIT template with a base TRAIT.(.
#define TRAIT_TEMPLATE(t, n, l)
 TRAIT template.
#define ANY_META_FUNCTION(pure_template_params, any_template_params_with_defaults, n)
#define __detail_ANYXX_ANY_CMF(t, t_with_defaults, n)
#define __detail_ANYXX_ANY_EX_(n, proxy_default)
#define ANY_EX_(n, BASE, l, proxy_default, decoration)
 ANY with a base and decorationSee ANY for explanation.
#define ANY_EX(n, l, proxy_default, decoration)
 ANY with decorationSee ANY for explanation.
#define ANY_(n, BASE, l, proxy_default)
 ANY with a baseSee ANY for explanation.
#define ANY(n, l, ...)
 Simple ANY macro.
#define __detail_ANYXX_ANY_TEMPLATE_CMF(t, n, proxy_default)
#define ANY_TEMPLATE_(t, n, BASE, bt, l, proxy_default)
 ANY template with a base.See ANY for explanation.
#define ANY_TEMPLATE_EX_(t, n, BASE, bt, l, proxy_default, decoration)
 ANY template with a base and decoration.See ANY for explanation.
#define ANY_TEMPLATE(t, n, l, proxy_default)
 ANY template.See ANY for explanation.
#define ANY_TEMPLATE_EX(t, n, l, proxy_default, static_fns, typedefs, decoration)
#define ANY_FN_PURE(ret, name, params, const_)
 TRAIT function, which must be provided by the model.
#define ANY_FN_PURE_EXACT(ret, name, params, const_)
 TRAIT function, which must be provided by the model.
#define ANY_FN_DEF(access, ret, name, params, const_, ...)
 TRAIT function with default behavior.
#define ANY_FN_EXACT(ret, name, params, const_)
 TRAIT function whose default behavior is to call an equally named member function of the model.
#define ANY_FN_STATIC_PURE(template_params, return_type, name, params, ...)
 Static TRAIT function, which must be provided by the model. This function will NOT go into the v-Table ad is only avalable for the using_ Proxy.
#define ANY_FN_STATIC_DEF(template_params, return_type, name, params, ...)
 Static TRAIT function, which has a default implementation. This function will NOT go into the v-Table ad is only avalable for the using_ und trait_class Proxy.
#define ANY_TYPE(...)
 Dependent type definition in a TRAIT. This is useful for defining associated types, e.g. Return typs using_ Proxy.

Detailed Description

Macros to define trait 's and any 's.

Name conventions:

  • TRAIT: macro to define the functional behavior of an any
  • ANY: macro to define a trait and a using for an any based on this with a template parameter for the proxy.
  • EX: macro with decorations (additional functions and typedefs in brackets). A decoration can be any valid C++ code fragment in the context of the trait jacket
  • TEMPLATE: macro to define a template trait or any
  • trailing underscore: macro with base TRAIT

Syntax:

TRAIT[_TEMPLATE][_EX][_] ([template_types], name, [base, base_template_types,] function_list[,(decoration)])

ANY[_TEMPLATE][_EX][_] ([template_types], name, [base, base_template_types,] function_list[,(decoration)])

Macro Definition Documentation

◆ __detail_ANYXX_ANY_CMF

#define __detail_ANYXX_ANY_CMF ( t,
t_with_defaults,
n )
Value:
ANY_META_FUNCTION(, _detail_REMOVE_PARENS(t_with_defaults), n)

◆ __detail_ANYXX_ANY_EX_

#define __detail_ANYXX_ANY_EX_ ( n,
proxy_default )
Value:
__detail_ANYXX_ANY_CMF( \
((Proxy)), ((Proxy = anyxx::default_proxy<proxy_default>::type)), n)

◆ __detail_ANYXX_ANY_TEMPLATE_CMF

#define __detail_ANYXX_ANY_TEMPLATE_CMF ( t,
n,
proxy_default )
Value:
ANY_META_FUNCTION(_detail_REMOVE_PARENS(t), \
__detail_ANYXX_ADD_TAIL( \
(Proxy = anyxx::default_proxy<proxy_default>::type), \
_detail_REMOVE_PARENS(t)), \
n)

◆ ANY

#define ANY ( n,
l,
... )
Value:
TRAIT(n, l) \
__detail_ANYXX_ANY_EX_(n, __VA_ARGS__)
#define TRAIT(n, fns)
Macro to define the functional behavior for an any.
Definition anyxx.hpp:774

Simple ANY macro.

The ANY macro uses TRAIT macros to define the functional behavior of an any. Additionally, it defines the proxy to be used (default_proxy). The default proxy is val. Example:

ANY(example_any,
(ANY_FN(void, example_fn_const, (double, std::string const&), const),
ANY_FN(int, example_fn_mutable, (int), ))
)
#define ANY_FN(ret, name, params, const_)
TRAIT function whose default behavior is to call an equally named member function of the model.
Definition anyxx.hpp:1019
#define ANY(n, l,...)
Simple ANY macro.
Definition anyxx.hpp:884

is equivalent to:

TRAIT(example,
(ANY_FN(void, example_fn_const, (double, std::string const&), const),
ANY_FN(int, example_fn_mutable, (int), ))
)
template <typename Proxy = anyxx::val<>>
using any_example = anyxx::any<Proxy, example>;
Examples
21_Tree_any.cpp, 21_Tree_any_borrow_as.cpp, 21_Tree_any_dispatch.cpp, 31_Animals_any_dispatch.cpp, X1_any_weak_const.cpp, _1_any_shape.cpp, _2c_trait_any_variant.cpp, and _3_any_range.cpp.

◆ ANY_

#define ANY_ ( n,
BASE,
l,
proxy_default )
Value:
TRAIT_(n, BASE, l) \
__detail_ANYXX_ANY_EX_(n, proxy_default)
#define TRAIT_(n, BASE, l)
TRAIT derived from base.
Definition anyxx.hpp:762

ANY with a baseSee ANY for explanation.

Examples
_1_any_shape.cpp.

◆ ANY_EX

#define ANY_EX ( n,
l,
proxy_default,
decoration )
Value:
TRAIT_EX(n, l, decoration) \
__detail_ANYXX_ANY_EX_(n, proxy_default)
#define TRAIT_EX(n,...)
TRAIT with decoration.
Definition anyxx.hpp:782

ANY with decorationSee ANY for explanation.

◆ ANY_EX_

#define ANY_EX_ ( n,
BASE,
l,
proxy_default,
decoration )
Value:
TRAIT_EX_(n, BASE, l, decoration) \
__detail_ANYXX_ANY_EX_(n, proxy_default)
#define TRAIT_EX_(n, BASE, l, static_fns, typedefs, decoration)
TRAIT derived from base with decoration. Macro to define the functional behavior for a any,...
Definition anyxx.hpp:756

ANY with a base and decorationSee ANY for explanation.

◆ ANY_FN_DEF

#define ANY_FN_DEF ( access,
ret,
name,
params,
const_,
... )
Value:
ANY_FN_(access, , ret, name, name, false, const_, (__VA_ARGS__), \
_detail_EXPAND params)

TRAIT function with default behavior.

Examples
_2b_trait_monoid.cpp, _2c_trait_any_variant.cpp, _2d_trait_self.cpp, and _3_any_range.cpp.

◆ ANY_FN_EXACT

#define ANY_FN_EXACT ( ret,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, , ret, name, name, true, const_, params)

TRAIT function whose default behavior is to call an equally named member function of the model.

Examples
_5_any_template.cpp.

◆ ANY_FN_PURE

#define ANY_FN_PURE ( ret,
name,
params,
const_ )
Value:
ANY_FN_(private, , ret, name, name, false, const_, \
(_detail_ANYXX_TRAIT_ERROR_MESSAGE(name, ret)), \
_detail_EXPAND params)

TRAIT function, which must be provided by the model.

◆ ANY_FN_PURE_EXACT

#define ANY_FN_PURE_EXACT ( ret,
name,
params,
const_ )
Value:
ANY_FN_(private, , ret, name, name, true, const_, \
(_detail_ANYXX_TRAIT_ERROR_MESSAGE(name, ret)), \
_detail_EXPAND params)

TRAIT function, which must be provided by the model.

◆ ANY_FN_STATIC_DEF

#define ANY_FN_STATIC_DEF ( template_params,
return_type,
name,
params,
... )
Value:
ANY_FN_(template_params, return_type, name, (__VA_ARGS__), \
_detail_EXPAND params)

Static TRAIT function, which has a default implementation. This function will NOT go into the v-Table ad is only avalable for the using_ und trait_class Proxy.

◆ ANY_FN_STATIC_PURE

#define ANY_FN_STATIC_PURE ( template_params,
return_type,
name,
params,
... )
Value:
ANY_FN_(template_params, return_type, name, \
(_detail_ANYXX_TRAIT_ERROR_MESSAGE(name, return_type)), \
_detail_EXPAND params)

Static TRAIT function, which must be provided by the model. This function will NOT go into the v-Table ad is only avalable for the using_ Proxy.

◆ ANY_META_FUNCTION

#define ANY_META_FUNCTION ( pure_template_params,
any_template_params_with_defaults,
n )
Value:
\
template <_detail_ANYXX_TYPENAME_PARAM_LIST( \
any_template_params_with_defaults)> \
using any_##n = anyxx::any<Proxy, n _detail_ANYXX_OPTIONAL_TEMPLATE_ARGS( \
pure_template_params)>;
The core class template to control dispatch for external polymorphism.
Definition anyxx.hpp:2806

◆ ANY_TEMPLATE

#define ANY_TEMPLATE ( t,
n,
l,
proxy_default )
Value:
TRAIT_TEMPLATE(t, n, l) \
__detail_ANYXX_ANY_TEMPLATE_CMF(t, n, proxy_default)
#define TRAIT_TEMPLATE(t, n, l)
TRAIT template.
Definition anyxx.hpp:819

ANY template.See ANY for explanation.

Examples
_5_any_template.cpp.

◆ ANY_TEMPLATE_

#define ANY_TEMPLATE_ ( t,
n,
BASE,
bt,
l,
proxy_default )
Value:
TRAIT_TEMPLATE_(t, n, BASE, bt, l) \
__detail_ANYXX_ANY_TEMPLATE_CMF(t, n, proxy_default)
#define TRAIT_TEMPLATE_(t, n, base, base_template_types, l)
TRAIT template with a base TRAIT.(.
Definition anyxx.hpp:813

ANY template with a base.See ANY for explanation.

◆ ANY_TEMPLATE_EX

#define ANY_TEMPLATE_EX ( t,
n,
l,
proxy_default,
static_fns,
typedefs,
decoration )
Value:
TRAIT_TEMPLATE_EX(t, n, l, static_fns, typedefs, decoration) \
__detail_ANYXX_ANY_TEMPLATE_CMF(t, n, proxy_default)
#define TRAIT_TEMPLATE_EX(t, n, l, static_fns, typedefs, decoration)
TRAIT template with decoration.
Definition anyxx.hpp:806

◆ ANY_TEMPLATE_EX_

#define ANY_TEMPLATE_EX_ ( t,
n,
BASE,
bt,
l,
proxy_default,
decoration )
Value:
TRAIT_TEMPLATE_EX_(t, n, BASE, bt, l, decoration) \
__detail_ANYXX_ANY_TEMPLATE_CMF(t, n, proxy_default)
#define TRAIT_TEMPLATE_EX_(t, n, base, base_template_types, l, static_fns, typedefs, decoration)
TRAIT template with base and decoration.
Definition anyxx.hpp:790

ANY template with a base and decoration.See ANY for explanation.

◆ ANY_TYPE

#define ANY_TYPE ( ...)
Value:
(__VA_ARGS__)

Dependent type definition in a TRAIT. This is useful for defining associated types, e.g. Return typs using_ Proxy.

Parameters
template_paramstemplate parameters for the type definition
namename of the type definition
erasedtype to be used in the erased context, to simpliy usage.
default_default type definition. Used undefined to request specification in the model_map

◆ TRAIT

#define TRAIT ( n,
fns )
Value:
TRAIT_(n, anyxx::base_trait, fns)

Macro to define the functional behavior for an any.

Example:

TRAIT(sample_trait,
(ANY_FN(std::string, const_fn, (double, std::string const&), const))
)
Examples
README.cpp, _2o_trait_simple.cpp, _3_any_range.cpp, and _5_any_template.cpp.

◆ TRAIT_

#define TRAIT_ ( n,
BASE,
l )
Value:
TRAIT_EX_(n, BASE, l, , , ())

TRAIT derived from base.

Examples
_2d_trait_self.cpp.

◆ TRAIT_EX

#define TRAIT_EX ( n,
... )
Value:
TRAIT_EX_(n, anyxx::base_trait, __VA_ARGS__)

TRAIT with decoration.

Macro to define the functional behavior for a any, with decorations. Decorations are additional functions and typedefs (in brackets).

Examples
_2b_trait_monoid.cpp.

◆ TRAIT_EX_

#define TRAIT_EX_ ( n,
BASE,
l,
static_fns,
typedefs,
decoration )
Value:
__detail_ANYXX_TRAIT_(, n, BASE, l, static_fns, typedefs, decoration)

TRAIT derived from base with decoration. Macro to define the functional behavior for a any, where the behavior of base is inherited. The decoration are additional functions and typedefs (in brackets).

◆ TRAIT_TEMPLATE

#define TRAIT_TEMPLATE ( t,
n,
l )
Value:
TRAIT_TEMPLATE_(t, n, anyxx::base_trait, (), l)

TRAIT template.

Examples
_5_any_template.cpp.

◆ TRAIT_TEMPLATE_

#define TRAIT_TEMPLATE_ ( t,
n,
base,
base_template_types,
l )
Value:
TRAIT_TEMPLATE_EX_(t, n, base, base_template_types, l, , , ())

TRAIT template with a base TRAIT.(.

Examples
_2d_trait_self.cpp, and _5_any_template.cpp.

◆ TRAIT_TEMPLATE_EX

#define TRAIT_TEMPLATE_EX ( t,
n,
l,
static_fns,
typedefs,
decoration )
Value:
TRAIT_TEMPLATE_EX_(t, n, anyxx::base_trait, (), l, static_fns, typedefs, \
decoration)

TRAIT template with decoration.

◆ TRAIT_TEMPLATE_EX_

#define TRAIT_TEMPLATE_EX_ ( t,
n,
base,
base_template_types,
l,
static_fns,
typedefs,
decoration )
Value:
TRAIT_META_FUNCTION( \
_detail_REMOVE_PARENS(t), \
__detail_ANYXX_ADD_HEAD((T), _detail_REMOVE_PARENS(t)), \
__detail_ANYXX_ADD_HEAD((Concrete), _detail_REMOVE_PARENS(t)), \
__detail_ANYXX_ADD_HEAD((StaticDispatchType), _detail_REMOVE_PARENS(t)), \
__detail_ANYXX_ADD_HEAD((V), _detail_REMOVE_PARENS(t)), n, base, \
_detail_REMOVE_PARENS(base_template_types), \
__detail_ANYXX_ADD_HEAD((T), \
_detail_REMOVE_PARENS(base_template_types)), \
l, static_fns, typedefs, decoration)

TRAIT template with base and decoration.

Macro to define the functional behavior for a any, with decorations. Decorations are additional functions and typedefs (in brackets).