4 ms·
The code in the article is actually less horrible than I expected from the title. However, it seems like a situation which could be more elegantly solved with X
by ge0rg 15y ago
The code in the article is actually less horrible than I expected from the title. However, it seems like a situation which could be more elegantly solved with X-Macros (http://drdobbs.com/cpp/184401387 http://drdobbs.com/cpp/184401387), provided that you consider X-Macros elegant.
X-Macros: you have a header file consisting of lines in the form of "FOO(name, type, defvalue);" and include it several times with different definitions for FOO.
- jacquesm 15y agoI don't particularly like include files in the middle of structs, but it looks like X macros might work. Thanks for the tip, I'll have a look at them to see if there is a way around that so that it would work from a 'top' included file as well. The project I'm working on has a single 'master include' file and I'd hate to break that convention.