Why .dup not work with multidimensional arrays?

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 8 08:23:30 PDT 2015


On Friday, 8 May 2015 at 15:13:14 UTC, Ali Çehreli wrote:
> On 05/08/2015 08:05 AM, Dennis Ritchie wrote:
>
> > why static int idx variable declared within a
> > function deepDup takes the values 1, 1, 1, 2, 2, 3, 4, as
> opposed to a
> > global variable static int idx, which receives the expected
> value of 1,
> > 2, 3, 4, 5, 6, 7 ?
>
> That's because every template instance is a different type (or 
> implementation). Just like the static variables of foo and bar 
> are separate below, so are the static variables of t!int and 
> t!float:
>
> void foo()
> {
>     static int i;
> }
>
> void bar()
> {
>     static int i;
> }
>
> void t(T)()
> {
>     static int i;
> }
>
> Ali

Thankы. Now everything is clear.


More information about the Digitalmars-d-learn mailing list