AFLOW
 
Loading...
Searching...
No Matches
aurostd_automatic_template.h File Reference

This file contains the preprocessor macros to ensure a proper instantiation of all aurostd functions. More...

Go to the source code of this file.

Macros

#define AST_UTYPE_BASE_NUM   int, unsigned int, float, double
 
#define AST_UTYPE_NUM   int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double
 
#define AST_UTYPE_NUM_COMPLEX    int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double, aurostd::xcomplex<float>, aurostd::xcomplex<double>, aurostd::xcomplex<long double>
 
#define AST_UTYPE_COMPLEX   aurostd::xcomplex<float>, aurostd::xcomplex<double>, aurostd::xcomplex<long double>
 
#define AST_UTYPE_NUM_STDCOMPLEX   int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double, std::complex<float>, std::complex<double>
 
#define AST_UTYPE_FLOAT   float, double, long double
 
#define AST_UTYPE_INT   int, long int, long long int
 
#define AST_UTYPE_AINT   int, unsigned int, long int, unsigned long int, long long int, unsigned long long int
 
#define AST_UTYPE_UINT   unsigned int, unsigned long int, unsigned long long int
 
#define AST_UTYPE_TEXT   std::string, char, char const*
 
#define AST_UTYPE_STRING   std::string
 
#define AST_UTYPE_CHAR   char
 
#define AST_UTYPE_BOOL   bool
 
#define AST_FIRST(a, ...)
 
#define AST_SECOND(a, b, ...)
 
#define AST_EMPTY()
 
#define AST_EVAL(...)
 
#define AST_EVAL1024(...)
 
#define AST_EVAL512(...)
 
#define AST_EVAL256(...)
 
#define AST_EVAL128(...)
 
#define AST_EVAL64(...)
 
#define AST_EVAL32(...)
 
#define AST_EVAL16(...)
 
#define AST_EVAL8(...)
 
#define AST_EVAL4(...)
 
#define AST_EVAL2(...)
 
#define AST_EVAL1(...)
 
#define AST_DEFER1(m)
 
#define AST_DEFER2(m)
 
#define AST_DEFER3(m)
 
#define AST_DEFER4(m)
 
#define AST_IS_AST_PROBE(...)
 
#define AST_PROBE()
 
#define AST_CAT(a, b)
 
#define AST_NOT(x)
 
#define _AST_NOT_0   AST_PROBE()
 
#define AST_BOOL(x)
 
#define AST_IF_ELSE(condition)
 
#define _AST_IF_ELSE(condition)
 
#define _IF_1(...)
 
#define _IF_0(...)
 
#define _IF_1_ELSE(...)
 
#define _IF_0_ELSE(...)
 
#define AST_HAS_ARGS(...)
 
#define AST_HAS_ARGS_2(skip1, ...)
 
#define AST_HAS_ARGS_3(skip1, skip2, ...)
 
#define _AST_END_OF_ARGUMENTS_()
 
#define AST_INVOKE(macro, ...)
 
#define AST_MAP(m, first, ...)
 
#define _AST_MAP()
 
#define AST_MAP2_1(m, first, ...)
 
#define _AST_MAP2_1()
 
#define AST_MAP2_2(m, first, ...)
 
#define _AST_MAP2_2()
 
#define AST_MAP2_2_SUB(m, first, second, ...)
 
#define _AST_MAP2_2_SUB()
 
#define AST_MAP3_1(m, first, ...)
 
#define _AST_MAP3_1()
 
#define AST_MAP3_2(m, first, ...)
 
#define _AST_MAP3_2()
 
#define AST_MAP3_2_SUB(m, first, second, ...)
 
#define _AST_MAP3_2_SUB()
 
#define AST_MAP3_3_SUB(m, first, second, third, ...)
 
#define _AST_MAP3_3_SUB()
 
#define AST_GEN_1(type_selection)
 autogenerate 1D code based on AST_TEMPLATE
 
#define AST_GEN_2(type_selection)
 autogenerate 2D code based on AST_TEMPLATE
 
#define AST_JSON_ACCESSOR(accessor, ...)
 autogenerate setters/getters for conversion between class members and json objects
 
#define JSON_GETTER(var)
 
#define JSON_SETTER(var)
 
#define AST_JSON_GETTER(...)
 Expands the getter: {#var, this->var} on each of members.
 
#define AST_JSON_SETTER(...)
 

Detailed Description

This file contains the preprocessor macros to ensure a proper instantiation of all aurostd functions.

Authors
20230622 | Hagen Eckert - auto template system
Note
the macro iterator logic is based on a blog post by Jonathan Heathcote
See also
Blog about macro iterator
source code examples next to the macros AST_GEN_1 AST_GEN_2 #AST_GEN_3

Definition in file aurostd_automatic_template.h.

Macro Definition Documentation

◆ AST_UTYPE_BASE_NUM

#define AST_UTYPE_BASE_NUM   int, unsigned int, float, double

Definition at line 19 of file aurostd_automatic_template.h.

◆ AST_UTYPE_NUM

#define AST_UTYPE_NUM   int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double

Definition at line 20 of file aurostd_automatic_template.h.

◆ AST_UTYPE_NUM_COMPLEX

#define AST_UTYPE_NUM_COMPLEX    int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double, aurostd::xcomplex<float>, aurostd::xcomplex<double>, aurostd::xcomplex<long double>

Definition at line 21 of file aurostd_automatic_template.h.

◆ AST_UTYPE_COMPLEX

#define AST_UTYPE_COMPLEX   aurostd::xcomplex<float>, aurostd::xcomplex<double>, aurostd::xcomplex<long double>

Definition at line 23 of file aurostd_automatic_template.h.

◆ AST_UTYPE_NUM_STDCOMPLEX

#define AST_UTYPE_NUM_STDCOMPLEX   int, unsigned int, long int, long unsigned int, long long int, long long unsigned int, float, double, long double, std::complex<float>, std::complex<double>

Definition at line 24 of file aurostd_automatic_template.h.

◆ AST_UTYPE_FLOAT

#define AST_UTYPE_FLOAT   float, double, long double

Definition at line 25 of file aurostd_automatic_template.h.

◆ AST_UTYPE_INT

#define AST_UTYPE_INT   int, long int, long long int

Definition at line 26 of file aurostd_automatic_template.h.

◆ AST_UTYPE_AINT

#define AST_UTYPE_AINT   int, unsigned int, long int, unsigned long int, long long int, unsigned long long int

Definition at line 27 of file aurostd_automatic_template.h.

◆ AST_UTYPE_UINT

#define AST_UTYPE_UINT   unsigned int, unsigned long int, unsigned long long int

Definition at line 28 of file aurostd_automatic_template.h.

◆ AST_UTYPE_TEXT

#define AST_UTYPE_TEXT   std::string, char, char const*

Definition at line 29 of file aurostd_automatic_template.h.

◆ AST_UTYPE_STRING

#define AST_UTYPE_STRING   std::string

Definition at line 30 of file aurostd_automatic_template.h.

◆ AST_UTYPE_CHAR

#define AST_UTYPE_CHAR   char

Definition at line 31 of file aurostd_automatic_template.h.

◆ AST_UTYPE_BOOL

#define AST_UTYPE_BOOL   bool

Definition at line 32 of file aurostd_automatic_template.h.

◆ AST_FIRST

#define AST_FIRST ( a,
... )
Value:
a

Definition at line 35 of file aurostd_automatic_template.h.

◆ AST_SECOND

#define AST_SECOND ( a,
b,
... )
Value:
b

Definition at line 36 of file aurostd_automatic_template.h.

◆ AST_EMPTY

#define AST_EMPTY ( )

Definition at line 38 of file aurostd_automatic_template.h.

◆ AST_EVAL

#define AST_EVAL ( ...)
Value:
AST_EVAL1024(__VA_ARGS__)
#define AST_EVAL1024(...)

Definition at line 40 of file aurostd_automatic_template.h.

◆ AST_EVAL1024

#define AST_EVAL1024 ( ...)
Value:
AST_EVAL512(AST_EVAL512(__VA_ARGS__))
#define AST_EVAL512(...)

Definition at line 41 of file aurostd_automatic_template.h.

◆ AST_EVAL512

#define AST_EVAL512 ( ...)
Value:
AST_EVAL256(AST_EVAL256(__VA_ARGS__))
#define AST_EVAL256(...)

Definition at line 42 of file aurostd_automatic_template.h.

◆ AST_EVAL256

#define AST_EVAL256 ( ...)
Value:
AST_EVAL128(AST_EVAL128(__VA_ARGS__))
#define AST_EVAL128(...)

Definition at line 43 of file aurostd_automatic_template.h.

◆ AST_EVAL128

#define AST_EVAL128 ( ...)
Value:
AST_EVAL64(AST_EVAL64(__VA_ARGS__))
#define AST_EVAL64(...)

Definition at line 44 of file aurostd_automatic_template.h.

◆ AST_EVAL64

#define AST_EVAL64 ( ...)
Value:
AST_EVAL32(AST_EVAL32(__VA_ARGS__))
#define AST_EVAL32(...)

Definition at line 45 of file aurostd_automatic_template.h.

◆ AST_EVAL32

#define AST_EVAL32 ( ...)
Value:
AST_EVAL16(AST_EVAL16(__VA_ARGS__))
#define AST_EVAL16(...)

Definition at line 46 of file aurostd_automatic_template.h.

◆ AST_EVAL16

#define AST_EVAL16 ( ...)
Value:
AST_EVAL8(AST_EVAL8(__VA_ARGS__))
#define AST_EVAL8(...)

Definition at line 47 of file aurostd_automatic_template.h.

◆ AST_EVAL8

#define AST_EVAL8 ( ...)
Value:
AST_EVAL4(AST_EVAL4(__VA_ARGS__))
#define AST_EVAL4(...)

Definition at line 48 of file aurostd_automatic_template.h.

◆ AST_EVAL4

#define AST_EVAL4 ( ...)
Value:
AST_EVAL2(AST_EVAL2(__VA_ARGS__))
#define AST_EVAL2(...)

Definition at line 49 of file aurostd_automatic_template.h.

◆ AST_EVAL2

#define AST_EVAL2 ( ...)
Value:
AST_EVAL1(AST_EVAL1(__VA_ARGS__))
#define AST_EVAL1(...)

Definition at line 50 of file aurostd_automatic_template.h.

◆ AST_EVAL1

#define AST_EVAL1 ( ...)
Value:
__VA_ARGS__

Definition at line 51 of file aurostd_automatic_template.h.

◆ AST_DEFER1

#define AST_DEFER1 ( m)
Value:
#define AST_EMPTY()

Definition at line 53 of file aurostd_automatic_template.h.

◆ AST_DEFER2

#define AST_DEFER2 ( m)
Value:

Definition at line 54 of file aurostd_automatic_template.h.

◆ AST_DEFER3

#define AST_DEFER3 ( m)
Value:

Definition at line 55 of file aurostd_automatic_template.h.

◆ AST_DEFER4

#define AST_DEFER4 ( m)
Value:

Definition at line 56 of file aurostd_automatic_template.h.

◆ AST_IS_AST_PROBE

#define AST_IS_AST_PROBE ( ...)
Value:
AST_SECOND(__VA_ARGS__, 0)
#define AST_SECOND(a, b,...)

Definition at line 58 of file aurostd_automatic_template.h.

◆ AST_PROBE

#define AST_PROBE ( )
Value:
~, 1

Definition at line 59 of file aurostd_automatic_template.h.

◆ AST_CAT

#define AST_CAT ( a,
b )
Value:
a##b

Definition at line 61 of file aurostd_automatic_template.h.

◆ AST_NOT

#define AST_NOT ( x)
Value:
AST_IS_AST_PROBE(AST_CAT(_AST_NOT_, x))
#define AST_CAT(a, b)
#define AST_IS_AST_PROBE(...)

Definition at line 63 of file aurostd_automatic_template.h.

◆ _AST_NOT_0

#define _AST_NOT_0   AST_PROBE()

Definition at line 64 of file aurostd_automatic_template.h.

◆ AST_BOOL

#define AST_BOOL ( x)
Value:
#define AST_NOT(x)

Definition at line 66 of file aurostd_automatic_template.h.

◆ AST_IF_ELSE

#define AST_IF_ELSE ( condition)
Value:
#define AST_BOOL(x)
#define _AST_IF_ELSE(condition)

Definition at line 68 of file aurostd_automatic_template.h.

◆ _AST_IF_ELSE

#define _AST_IF_ELSE ( condition)
Value:
AST_CAT(_IF_, condition)

Definition at line 69 of file aurostd_automatic_template.h.

◆ _IF_1

#define _IF_1 ( ...)
Value:
__VA_ARGS__ _IF_1_ELSE
#define _IF_1_ELSE(...)

Definition at line 71 of file aurostd_automatic_template.h.

◆ _IF_0

#define _IF_0 ( ...)
Value:
#define _IF_0_ELSE(...)

Definition at line 72 of file aurostd_automatic_template.h.

◆ _IF_1_ELSE

#define _IF_1_ELSE ( ...)

Definition at line 74 of file aurostd_automatic_template.h.

◆ _IF_0_ELSE

#define _IF_0_ELSE ( ...)
Value:
__VA_ARGS__

Definition at line 75 of file aurostd_automatic_template.h.

◆ AST_HAS_ARGS

#define AST_HAS_ARGS ( ...)
Value:
#define AST_FIRST(a,...)
#define _AST_END_OF_ARGUMENTS_()

Definition at line 77 of file aurostd_automatic_template.h.

◆ AST_HAS_ARGS_2

#define AST_HAS_ARGS_2 ( skip1,
... )
Value:

Definition at line 78 of file aurostd_automatic_template.h.

◆ AST_HAS_ARGS_3

#define AST_HAS_ARGS_3 ( skip1,
skip2,
... )
Value:

Definition at line 79 of file aurostd_automatic_template.h.

◆ _AST_END_OF_ARGUMENTS_

#define _AST_END_OF_ARGUMENTS_ ( )
Value:
0

Definition at line 80 of file aurostd_automatic_template.h.

◆ AST_INVOKE

#define AST_INVOKE ( macro,
... )
Value:
macro(__VA_ARGS__)

Definition at line 81 of file aurostd_automatic_template.h.

◆ AST_MAP

#define AST_MAP ( m,
first,
... )
Value:
m(first) AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER2(_AST_MAP)()(m, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define AST_IF_ELSE(condition)
#define AST_DEFER2(m)
#define AST_HAS_ARGS(...)
#define _AST_MAP()

Definition at line 85 of file aurostd_automatic_template.h.

◆ _AST_MAP

#define _AST_MAP ( )
Value:
#define AST_MAP(m, first,...)

Definition at line 88 of file aurostd_automatic_template.h.

◆ AST_MAP2_1

#define AST_MAP2_1 ( m,
first,
... )
Value:
m(first, first) AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER2(_AST_MAP2_1)()(m, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define _AST_MAP2_1()

Definition at line 91 of file aurostd_automatic_template.h.

◆ _AST_MAP2_1

#define _AST_MAP2_1 ( )
Value:
#define AST_MAP2_1(m, first,...)

Definition at line 94 of file aurostd_automatic_template.h.

◆ AST_MAP2_2

#define AST_MAP2_2 ( m,
first,
... )
Value:
AST_DEFER3(AST_MAP2_2_SUB(m, first, __VA_ARGS__)) \
AST_IF_ELSE(AST_HAS_ARGS_2(__VA_ARGS__))(AST_DEFER2(_AST_MAP2_2)()(m, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define AST_DEFER3(m)
#define _AST_MAP2_2()
#define AST_MAP2_2_SUB(m, first, second,...)
#define AST_HAS_ARGS_2(skip1,...)

Definition at line 96 of file aurostd_automatic_template.h.

◆ _AST_MAP2_2

#define _AST_MAP2_2 ( )
Value:
#define AST_MAP2_2(m, first,...)

Definition at line 100 of file aurostd_automatic_template.h.

◆ AST_MAP2_2_SUB

#define AST_MAP2_2_SUB ( m,
first,
second,
... )
Value:
m(first, second) m(second, first) AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER2(_AST_MAP2_2_SUB)()(m, first, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define _AST_MAP2_2_SUB()

Definition at line 102 of file aurostd_automatic_template.h.

◆ _AST_MAP2_2_SUB

#define _AST_MAP2_2_SUB ( )
Value:

Definition at line 105 of file aurostd_automatic_template.h.

◆ AST_MAP3_1

#define AST_MAP3_1 ( m,
first,
... )
Value:
m(first, first, first) AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER2(_AST_MAP3_1)()(m, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define _AST_MAP3_1()

Definition at line 108 of file aurostd_automatic_template.h.

◆ _AST_MAP3_1

#define _AST_MAP3_1 ( )
Value:
#define AST_MAP3_1(m, first,...)

Definition at line 111 of file aurostd_automatic_template.h.

◆ AST_MAP3_2

#define AST_MAP3_2 ( m,
first,
... )
Value:
AST_DEFER4(AST_MAP3_2_SUB(m, first, __VA_ARGS__)) \
AST_IF_ELSE(AST_HAS_ARGS_3(__VA_ARGS__))(AST_DEFER3(_AST_MAP3_2)()(m, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define AST_DEFER4(m)
#define AST_HAS_ARGS_3(skip1, skip2,...)
#define _AST_MAP3_2()
#define AST_MAP3_2_SUB(m, first, second,...)

Definition at line 113 of file aurostd_automatic_template.h.

◆ _AST_MAP3_2

#define _AST_MAP3_2 ( )
Value:
#define AST_MAP3_2(m, first,...)

Definition at line 117 of file aurostd_automatic_template.h.

◆ AST_MAP3_2_SUB

#define AST_MAP3_2_SUB ( m,
first,
second,
... )
Value:
m(first, second, second) m(second, first, second) m(second, second, first) m(second, first, first) m(first, second, first) \
AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER3(AST_MAP3_3_SUB(m, first, second, __VA_ARGS__)) AST_DEFER2(_AST_MAP3_2_SUB)()(m, first, __VA_ARGS__))( /* Do nothing, just terminate */ \
)
#define _AST_MAP3_2_SUB()
#define AST_MAP3_3_SUB(m, first, second, third,...)

Definition at line 119 of file aurostd_automatic_template.h.

◆ _AST_MAP3_2_SUB

#define _AST_MAP3_2_SUB ( )
Value:

Definition at line 123 of file aurostd_automatic_template.h.

◆ AST_MAP3_3_SUB

#define AST_MAP3_3_SUB ( m,
first,
second,
third,
... )
Value:
m(first, second, third) m(first, third, second) m(second, first, third) m(second, third, first) m(third, first, second) m(third, second, first) \
AST_IF_ELSE(AST_HAS_ARGS(__VA_ARGS__))(AST_DEFER2(AST_MAP3_3_SUB(m, first, second, __VA_ARGS__)))( /* Do nothing, just terminate */ \
)

Definition at line 125 of file aurostd_automatic_template.h.

◆ _AST_MAP3_3_SUB

#define _AST_MAP3_3_SUB ( )
Value:

Definition at line 129 of file aurostd_automatic_template.h.

◆ AST_GEN_1

#define AST_GEN_1 ( type_selection)
Value:
#define AST_TEMPLATE(atype)
#define AST_EVAL(...)
#define AST_INVOKE(macro,...)

autogenerate 1D code based on AST_TEMPLATE

Parameters
type_selectionuse one of the AST_UTYPE_*
Note
always define the AST_TEMPLATE before using this macro function
#define AST_TEMPLATE(utype) template class xvector<utype>;
#undef AST_TEMPLATE
#define AST_GEN_1(type_selection)
autogenerate 1D code based on AST_TEMPLATE
#define AST_UTYPE_NUM
the preprocessor will generate (without newlines):
template class xvector<int>;
template class xvector<unsigned int>;
template class xvector<long int>;
template class xvector<long long int>;
template class xvector<float>;
template class xvector<double>;
template class xvector<long double>;

Definition at line 151 of file aurostd_automatic_template.h.

◆ AST_GEN_2

#define AST_GEN_2 ( type_selection)
Value:
AST_EVAL(AST_INVOKE(AST_MAP2_2, AST_TEMPLATE, type_selection))

autogenerate 2D code based on AST_TEMPLATE

Parameters
type_selectionuse one of the AST_UTYPE_*
Note
always define the AST_TEMPLATE before using this macro function
#define AST_TEMPLATE(atype, btype) template xvector<atype> xvector2utype(const xvector<btype>& a);
#undef AST_TEMPLATE
#define AST_GEN_2(type_selection)
autogenerate 2D code based on AST_TEMPLATE
#define AST_UTYPE_FLOAT
the preprocessor will generate (without newlines):
template xvector<float> xvector2utype(const xvector<float>& a);
template xvector<double> xvector2utype(const xvector<double>& a);
template xvector<long double> xvector2utype(const xvector<long double>& a);
template xvector<float> xvector2utype(const xvector<double>& a);
template xvector<double> xvector2utype(const xvector<float>& a);
template xvector<float> xvector2utype(const xvector<long double>& a);
template xvector<long double> xvector2utype(const xvector<float>& a);
template xvector<double> xvector2utype(const xvector<long double>& a);
template xvector<long double> xvector2utype(const xvector<double>& a);

Definition at line 173 of file aurostd_automatic_template.h.

◆ AST_JSON_ACCESSOR

#define AST_JSON_ACCESSOR ( accessor,
... )
Value:
AST_EVAL(AST_INVOKE(AST_MAP, accessor, __VA_ARGS__))

autogenerate setters/getters for conversion between class members and json objects

Parameters
accessorthe setter or getter macro to use as a mapping
membersthe macro defining the list of members to expand on
Note
this simply just maps the accessor macro over the elements of the members macro

Definition at line 181 of file aurostd_automatic_template.h.

◆ JSON_GETTER

#define JSON_GETTER ( var)
Value:
{#var, this->var},

Definition at line 183 of file aurostd_automatic_template.h.

◆ JSON_SETTER

#define JSON_SETTER ( var)
Value:
this->var = static_cast<decltype(var)>(jo[#var]);
Note
This assumes the json object is named jo

Definition at line 185 of file aurostd_automatic_template.h.

◆ AST_JSON_GETTER

#define AST_JSON_GETTER ( ...)
Value:
#define JSON_GETTER(var)
#define AST_JSON_ACCESSOR(accessor,...)
autogenerate setters/getters for conversion between class members and json objects

Expands the getter: {#var, this->var} on each of members.

Definition at line 188 of file aurostd_automatic_template.h.

◆ AST_JSON_SETTER

#define AST_JSON_SETTER ( ...)
Value:
#define JSON_SETTER(var)

Expands the setter: this->var = static_cast<decltype(var)>(jo[#var]);

Note
This assumes the json object is named jo

Definition at line 191 of file aurostd_automatic_template.h.