array depth template

BCS none at anon.com
Thu Jun 11 19:15:46 PDT 2009


Hello Saaa,

> Is this a good way to get the depth of an array?
> 
> int getArrayDepth(T)(ref T array)
> {
> static if( is(T A:A[]) )
> {
> A arr;
> return 1 + getArrayDepth(arr);
> }
> else
> {
> return 0;
> }
> return -1;
> }

I just posted this today

http://www.dsource.org/projects/scrapple/browser/trunk/Serial/utill.d




More information about the Digitalmars-d-learn mailing list