Template metaprograms have different categories of C++ types/constructions acting as different elements of the metaprogram syntax.
The utility eval (Abbreviated to the macro $()) takes any metaprogram expression and evaluates it. To be able to get the correct value of the expression, eval should handle the different categories of constructions mentioned above, acting accordingly.
Here those categories are defined as concepts:
Value
Plain C++ type with any special characteristics (See concepts bellow). The result of evaluating a value is the value itself:
template<typename T>
using eval_value = T;
Metafunction
A metafunction is any C++ type with a type member type/alias. Nullary metafunctions are supported.
An is_metafunction trait should be provided. Possible implementation:
If the metafunction is not a nullary metafunction, its parameters should be evaluated first prior to metafunction evaluation,. This process is called _parameter expansion_.
Metafunction parameter expansion could be explicitly disabled if needed by a noexpand type member on the metafunction.
Metafunction class
A metafunction class is any C++ type with a member apply metafunction. Nullary metafunction classes are supported (Note that means apply could be a type or a template).
An is_metafunction_class should be provided. Possible implementation:
Check core_concepts.hpp and new_eval.hpp files at concepts-lite branch. The later is not working due to bugs on gcc-clite. The former also needed some workarounds against bugs.
Template metaprograms have different categories of C++ types/constructions acting as different elements of the metaprogram syntax. The utility
eval
(Abbreviated to the macro$()
) takes any metaprogram expression and evaluates it. To be able to get the correct value of the expression,eval
should handle the different categories of constructions mentioned above, acting accordingly.Here those categories are defined as concepts:
Value
Plain C++ type with any special characteristics (See concepts bellow). The result of evaluating a value is the value itself:
Metafunction
A metafunction is any C++ type with a
type
member type/alias. Nullary metafunctions are supported. Anis_metafunction
trait should be provided. Possible implementation:To evaluate a metafunction means to get its
type
member, that is:Live example.
If the metafunction is not a nullary metafunction, its parameters should be evaluated first prior to metafunction evaluation,. This process is called _parameter expansion_. Metafunction parameter expansion could be explicitly disabled if needed by a
noexpand
type member on the metafunction.Metafunction class
A metafunction class is any C++ type with a member
apply
metafunction. Nullary metafunction classes are supported (Note that meansapply
could be a type or a template). Anis_metafunction_class
should be provided. Possible implementation:Live example.
To evaluate a metafunction class means to evaluate its internal
apply
metafunction. Possible implementation: