In C++ this works:

struct test
{
        unsigned int h : 2;
};

int main()
{
        test b;
        b.h = 0;
        for(int i = 0;i < 10;i++)
                ++b.h;
        return 0;
}

In D this throws an exception as soon as it wraps:

struct test
{
        mixin(bitfields!(
                                         uint, "h", 2,
                                         uint, "", 30));
};

int main()
{
        test b;
        b.h = 0;
        for(int i = 0;i < 10;i++)
                b.h = b.h + 1;
        return 0;
}

Is there any way to make it work directly like the C++ example without doing something like
if(bitfield is at max)
    wrap it by hand;

It also seems odd to leave out the various shortcut operators like ++, *= etc fr bitfields.

Reply via email to