isPow2E

ditto, avoids a jump instruction.

bool
isPow2E
(
T
)
(
T x
)
if (
isIntegral!T
)

Examples

import std.meta : AliasSeq;
foreach (fn; AliasSeq!(isPow2, isPow2A, isPow2D, isPow2E, isPow2F))
{
    // run-time
    assert(!fn(7));
    assert(fn(8));
    assert(!fn(9));

    // compile-time
    static assert(!fn(7));
    static assert(fn(8));
    static assert(!fn(9));

    assert(!fn(0));
    assert(fn(1));
    assert(fn(2));
    assert(!fn(3));
    assert(fn(4));
    assert(!fn(5));
    assert(!fn(6));
    assert(!fn(7));
    assert(fn(8));
}

Meta