Convert this C macro kroundup32 to D mixin?

biocyberman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 8 02:53:47 PDT 2017


What is the D mixin version equivalent to this macro:

#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, 
(x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))

The macro looks cryptic. What the macro does has been explained 
here: 
http://stackoverflow.com/questions/3384852/could-someone-help-explain-what-this-c-one-liner-does

But I still don't know how to convert that to D mixin. I would 
like 'mixin' instead of a function is to avoid function call 
overhead. Also because it is short, so I think a mixin is enough, 
not a 'template mixin'.




More information about the Digitalmars-d-learn mailing list