aimstil  5.0.5
TExprMacros.h
Go to the documentation of this file.
1 #ifndef TIL_TEXPR_MACROS_H
2 #define TIL_TEXPR_MACROS_H
3 
7 
8 
9 //#define EXPRFUNC_1ARG(name, body) EXPRFUNC_1ARG_RET(name, body, typename TypeStruct<Iterator1>::Type)
10 //#define EXPRFUNC_2ARG(name, body) EXPRFUNC_2ARG_RET(name, body, typename TypeStruct<Iterator1 TIL_COMMA Iterator2>::Type)
11 //#define EXPRFUNC_3ARG(name, body) EXPRFUNC_3ARG_RET(name, body, typename TypeStruct<Iterator1 TIL_COMMA Iterator2 TIL_COMMA Iterator3>::Type)
12 #define EXPRFUNC_1ARG(name, body) EXPRFUNC_1ARG_ARG(name, body, i1)
13 #define EXPRFUNC_2ARG(name, body) EXPRFUNC_2ARG_ARG(name, body, i1, i2)
14 #define EXPRFUNC_3ARG(name, body) EXPRFUNC_3ARG_ARG(name, body, i1, i2, i3)
15 
16 #define TIL_COMMA ,
17 
18 // TODO: prefix TIL_ to those macro names.
19 
20 #define EXPRFUNC_1ARG_RET(name, body, ret) EXPRFUNC_1ARG_FULL(name, body, ret, i1)
21 #define EXPRFUNC_2ARG_RET(name, body, ret) EXPRFUNC_2ARG_FULL(name, body, ret, i1, i2)
22 #define EXPRFUNC_3ARG_RET(name, body, ret) EXPRFUNC_3ARG_FULL(name, body, ret, i1, i2, i3)
23 
24 #define EXPRFUNC_1ARG_ARG(name, body, arg1) EXPRFUNC_1ARG_FULL(name, body, typename TypeStruct<Iterator1>::Type, arg1)
25 #define EXPRFUNC_2ARG_ARG(name, body, arg1, arg2) EXPRFUNC_2ARG_FULL(name, body, typename TypeStruct<Iterator1 TIL_COMMA Iterator2>::Type, arg1, arg2)
26 #define EXPRFUNC_3ARG_ARG(name, body, arg1, arg2, arg3) EXPRFUNC_3ARG_FULL(name, body, typename TypeStruct<Iterator1 TIL_COMMA Iterator2 TIL_COMMA Iterator3>::Type, arg1, arg2, arg3)
27 
28 
29 #define EXPRFUNC_1ARG_FULL(name, body, ret, arg1) \
30 template < class Iterator1 > \
31 ret \
32 name (Iterator1 & arg1) \
33 { \
34 body \
35 } \
36 
37 #define EXPRFUNC_2ARG_FULL(name, body, ret, arg1, arg2) \
38 template < class Iterator1, class Iterator2> \
39 ret \
40 name (Iterator1 & arg1, Iterator2 & arg2) \
41 { \
42 body \
43 } \
44 
45 #define EXPRFUNC_3ARG_FULL(name, body, ret, arg1, arg2, arg3) \
46 template < class Iterator1, class Iterator2, class Iterator3 > \
47 ret \
48 name (Iterator1 & arg1, Iterator2 & arg2, Iterator3 & arg3) \
49 { \
50 body \
51 } \
52 
53 
54 
58 #define EXPR_RESULT_TYPE(rettype) \
59 template < class Iterator1, class Iterator2 = Iterator1, class Iterator3 = Iterator1> \
60 struct TypeStruct \
61 { \
62 typedef rettype Type; \
63 } \
64 
65 #define EXPR_ITERATORTYPE(rettype) \
66 template < class Iterator1, class Iterator2 = Iterator1, class Iterator3 = Iterator1> \
67 struct IteratorStruct \
68 { \
69 typedef rettype Type; \
70 } \
71 
72 
73 #endif
74