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 }