May 02, 2014 Re: D equivalent of the X macro? | ||||
---|---|---|---|---|
| ||||
On 05/02/14 02:22, H. S. Teoh via Digitalmars-d wrote:
> I was reading this article of Walter's:
>
> http://www.drdobbs.com/cpp/the-x-macro/228700289
>
> Which is a neat trick that I wish I'd known back when I was writing C/C++. But the thought crossed my mind: what's the D equivalent of the X macro, since D doesn't have macros? Any ideas?
Enums, mixins and CTFE.
For example, create an enum array, even an associative one, iterate over
the data at CT, generate the necessary code (and/or data), then mix it all in
at the right place.
artur
|
Copyright © 1999-2021 by the D Language Foundation