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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -