Base type for arrays

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 17 13:20:27 PDT 2015


On Wednesday, 17 June 2015 at 20:06:54 UTC, Alex Parrill wrote:

>
> Try:
>
> void foo(T)(T[] arg) {
>     // In here, T should be the element type, and T[] the array 
> type.
> }
>
> Not a general solution, but you mentioned that you wanted this 
> for a function parameter.

I don't think this works for multi-dimensional arrays. I tried

void foo(T)(T[] arg)
	if (isArray!(T[]) && is(T == real))
{
     writeln("foo has run for ", arg);
}

and it only worked on the one-dimensional one.


More information about the Digitalmars-d-learn mailing list