c++ - Metaprogramming via macro -
i’d same stuff can d’s mixins c/c++ preprocessor. i’d write function generate parameter list. instance:
#define mk_fn_foo(n,t) … mk_fn_foo(3,float) /* expand */ void foo(float x0, float x1, float x2) { /* else here */ }
i have idea i’m facing issue. have recursion , have no idea how such thing:
#define mk_foo(n,t) void foo(mk_foo_plist(n-1,t)) { } #define mk_foo_plist(n,t) t xn, mk_foo_plist(n-1,t) /* how stop that?! */
the boost libraries have vast extensive metaprogramming , else preprocessor library. possible kind of thing using utility preprocessor directives easier doing yourself, although still confusing :)
i suggest start there:
http://www.boost.org/doc/libs/1_53_0/libs/preprocessor/doc/index.html
http://www.boost.org/doc/libs/?view=category_preprocessor
edit: here tutorial them: boost.preprocessor - tutorial
Comments
Post a Comment