Any++
Loading...
Searching...
No Matches
ANY_FN... and ANY_OP macros

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

Macros

#define ANY_FN_DEF_EXACT(access, ret, name, params, const_, ...)
 TRAIT function with default behavior.
#define ANY_FN(ret, name, params, const_)
 TRAIT function whose default behavior is to call an equally named member function of the model.
#define ANY_FN_OVERLOAD(ret, name, params, const_)
 TRAIT function whose default behavior is to call an equally named member function of the model.
#define ANY_FN_OVERLOAD_EXACT(ret, name, params, const_)
 TRAIT function whose default behavior is to call an equally named member function of the model.
#define ANY_OP_MAP_NAMED(ret, op, name, params, const_)
 TRAIT operator with default behavior is to call the related operator of the model and a programmer-chosen name in the map.
#define ANY_OP(ret, op, params, const_)
 TRAIT operator with default behavior is to call the related operator of the model.
#define ANY_OP_DEF(access, ret, op, name, params, const_, ...)
 TRAIT operator with default behavior.
#define ANY_OP_EXACT_MAP_NAMED(ret, op, name, params, const_)
#define ANY_OP_EXACT(ret, op, params, const_)
#define ANY_OP_EXACT_DEF(access, ret, op, name, params, const_, ...)
 TRAIT operator with default behavior is to call the related operator of the model.
#define ANY_OP_EXACT_OVERLOAD_MAP_NAMED(ret, op, name, params, const_)
 TRAIT operator with default behavior and a programmer-chosen name in the map.
#define ANY_OP_EXACT_OVERLOAD(ret, op, params, const_)
 TRAIT operator with default behavior is to call the related operator of the model.
#define ANY_OP_EXACT_OVERLOAD_DEF(access, ret, op, name, params, const_, ...)
 TRAIT operator with default behavior.

Detailed Description

Macros to define trait's and any's functions and operators.

Name conventions:

  • FN: function
  • OP: operator
  • PURE: function must be provided by the model
  • DEF: function has a default behavior defined by the last parameter. Must be a lambda. The target model can be accessed via a capture in the lambda of the varaible x. This lambda is the last parameter of the macro.
  • OVERLOAD: use if in a base TRAIT exists an equally named FN or OP
  • MAP_NAMED: use to provide a programmer-chosen name for an operator in the map to have an defined name for overriding in derived TRAITs
  • EXACT: constness of the function must be matched exactly by the proxy. That means, if the function is const, the proxy must be const as well. Useful for functions and operators which have a seperate behavior for const and mutable objects, e.g., operator[]. — no suffix: function whose default behavior is to call an equally named member function of the model

Some FN/OP forms allow an access specifier. This specifier means

  • private: this FN/OP must be specified in every model_map. No default available.
  • protected: this FN/OP must be specified in every model_map. A default implementation is available in ..._default_model_map.
  • public: this FN/OP can be specified in every model_map. If it is not specified there, then the default implementation from ..._default_model_map is used.

syntax:

ANY_FN[_OVERLOAD]([_PURE]|[_DEF])[_EXCACT][] ([access], return_type, name, (param_list),[_const] [, default_behavior])

ANY_OP[_OVERLOAD][_MAP_NAMED]([_DEF]|[_EXACT_DEF] ([access], return_type, operator [,map_name], (param_list), [_const] [, default_behavior])

Macro Definition Documentation

◆ ANY_FN

#define ANY_FN ( ret,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, , ret, name, name, false, const_, params)

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

Example:

TRAIT(example_trait,
(ANY_FN(int, example_fn_const, (double, std::string const&), const),
ANY_FN(void, 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 TRAIT(n, fns)
Macro to define the functional behavior for an any.
Definition anyxx.hpp:774
Examples
21_Tree_any.cpp, 21_Tree_any_borrow_as.cpp, 31_Animals_any_dispatch.cpp, README.cpp, X1_any_weak_const.cpp, _1_any_shape.cpp, _2o_trait_simple.cpp, and _5_any_template.cpp.

◆ ANY_FN_DEF_EXACT

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

TRAIT function with default behavior.

◆ ANY_FN_OVERLOAD

#define ANY_FN_OVERLOAD ( ret,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, ANY_OVERLOAD(name), ret, name, name, false, \
const_, params)

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

Use if in a base TRAIT exists an equally named FN.

◆ ANY_FN_OVERLOAD_EXACT

#define ANY_FN_OVERLOAD_EXACT ( ret,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, ANY_OVERLOAD(name), ret, name, name, true, \
const_, params)

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

Use if in a base TRAIT exists an equally named FN.

◆ ANY_OP

#define ANY_OP ( ret,
op,
params,
const_ )
Value:
ANY_OP_MAP_NAMED(ret, op, _detail_CONCAT(__op__, __COUNTER__), params, const_)
#define ANY_OP_MAP_NAMED(ret, op, name, params, const_)
TRAIT operator with default behavior is to call the related operator of the model and a programmer-ch...
Definition anyxx.hpp:1052

TRAIT operator with default behavior is to call the related operator of the model.

◆ ANY_OP_DEF

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

TRAIT operator with default behavior.

Use if in a base TRAIT exists an equally named FN.

Examples
_2b_trait_monoid.cpp, and _2d_trait_self.cpp.

◆ ANY_OP_EXACT

#define ANY_OP_EXACT ( ret,
op,
params,
const_ )
Value:
ANY_OP_EXACT_MAP_NAMED(ret, op, _detail_CONCAT(__op__, __COUNTER__), params, \
const_)

◆ ANY_OP_EXACT_DEF

#define ANY_OP_EXACT_DEF ( access,
ret,
op,
name,
params,
const_,
... )
Value:
ANY_FN_(access, , ret, name, operator op, true, const_, (__VA_ARGS__), \
_detail_EXPAND params)

TRAIT operator with default behavior is to call the related operator of the model.

Use if in a base TRAIT exists an equally named FN.

◆ ANY_OP_EXACT_MAP_NAMED

#define ANY_OP_EXACT_MAP_NAMED ( ret,
op,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, , ret, name, operator op, true, const_, \
params)

◆ ANY_OP_EXACT_OVERLOAD

#define ANY_OP_EXACT_OVERLOAD ( ret,
op,
params,
const_ )
Value:
ret, op, _detail_CONCAT(__op__, __COUNTER__), params, const_)
#define ANY_OP_EXACT_OVERLOAD_MAP_NAMED(ret, op, name, params, const_)
TRAIT operator with default behavior and a programmer-chosen name in the map.
Definition anyxx.hpp:1096

TRAIT operator with default behavior is to call the related operator of the model.

Use if in a base TRAIT exists an equally named FN.

◆ ANY_OP_EXACT_OVERLOAD_DEF

#define ANY_OP_EXACT_OVERLOAD_DEF ( access,
ret,
op,
name,
params,
const_,
... )
Value:
ANY_FN_(access, ANY_OVERLOAD(operator op), ret, name, operator op, true, \
const_, (__VA_ARGS__), _detail_EXPAND params)

TRAIT operator with default behavior.

Use if in a base TRAIT exists an equally named FN.

◆ ANY_OP_EXACT_OVERLOAD_MAP_NAMED

#define ANY_OP_EXACT_OVERLOAD_MAP_NAMED ( ret,
op,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(ANY_OVERLOAD(operator op), ret, name, operator op, \
true, const_, params)

TRAIT operator with default behavior and a programmer-chosen name in the map.

Use if in a base TRAIT exists an equally named FN.

◆ ANY_OP_MAP_NAMED

#define ANY_OP_MAP_NAMED ( ret,
op,
name,
params,
const_ )
Value:
__detail_ANYXX_MEMBER_FN(public, , ret, name, operator op, false, const_, \
params)

TRAIT operator with default behavior is to call the related operator of the model and a programmer-chosen name in the map.

Use if in a base TRAIT exists an equally named FN.