On Friday, 1 May 2015 at 23:22:31 UTC, Dennis Ritchie wrote:
Maybe someone will show a primitive packed array. I really can not imagine how to do it on D.
                
Maybe you can somehow use bitfields. While what happened is something like this:

-----
import std.stdio, std.bitmanip;

struct A
{
        mixin(bitfields!(
                        uint, "bit",  6,
                        bool, "flag1", 1,
                        bool, "flag2", 1));
}


void main() {

        A obj;

        int[] a;

        foreach (e; 0 .. 64) {
                obj.bit = e;
                a ~= e;
        }

        writeln(a);

        // obj.bit = 64; // Value is greater than
        //the maximum value of bitfield 'bit'
}
-----
http://ideone.com/Opr4zM

Reply via email to