How to detect if an array if dynamic or static
mahdi via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 24 20:44:58 PST 2016
On Wednesday, 24 February 2016 at 22:38:04 UTC, Adam D. Ruppe
wrote:
> On Wednesday, 24 February 2016 at 21:48:14 UTC, mahdi wrote:
>> How can we detect is `array` is static (fixed size) or
>> dynamic, inside the function body?
>
> `array` there is always dynamic because it is not of a fixed
> size type.
>
> Why do you want to know though?
I thought we can simply denote `int[] x` in case we have an array
argument in D functions. So according to your answer if a
function expects a static array, it has to specify size of array
in parameter declaration:
void diss(int[3] array) ... //this expects a static array of
size 3
void diss(int[] array) ... //this expects a dynamic array
is this correct?
More information about the Digitalmars-d-learn
mailing list