On Saturday, 8 April 2017 at 10:02:01 UTC, Mike Parker wrote:
I would expect if you implement it as a function the compiler will inline it. You can always use the pragma(inline, true) [1] with -inline to verify.[1] https://dlang.org/spec/pragma.html#inline
This gives me no error, so it does inline it.
T kroundup32(T)(T x) {
pragma(inline, true);
--(x);
(x)|=(x)>>1;
(x)|=(x)>>2;
(x)|=(x)>>4;
(x)|=(x)>>8;
(x)|=(x)>>16;
return ++(x);
}
