arrays and .sizeof

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Aug 9 05:56:09 PDT 2011


Could this work?

import std.stdio;
import std.range;

size_t bcount(T)(T t)
{
    return (ElementType!T).sizeof * t.length;
}

void main()
{
    int[] a = [1, 2, 3, 4, 5, 6];
    writeln(a.bcount);  // 24
}


More information about the Digitalmars-d mailing list