cloning array

cc cc at nevernet.com
Thu Jun 3 10:42:16 UTC 2021


On Wednesday, 2 June 2021 at 17:50:13 UTC, Sean wrote:
> On Wednesday, 2 June 2021 at 15:32:38 UTC, Sean wrote:
>> if so, how can I get the behavior i am searching for? Thank 
>> you.
>
> My current solution, if anyone wonders : 
> https://github.com/patefacio/d-help/blob/master/d-help/opmix/dup.d

You may find the `hasIndirections` template from std.traits 
useful.

```d
import std.traits : hasIndirections, ValueType;
import std.range.primitives : ElementType;
int[] a;
int[][] b;
int[string] x;
int[][string] y;
struct S { int s; }
struct T { int[] t; }

assert(!hasIndirections!( ElementType!(typeof(a)) ));
assert( hasIndirections!( ElementType!(typeof(b)) ));
assert(!hasIndirections!( ValueType!(typeof(x)) ));
assert( hasIndirections!( ValueType!(typeof(y)) ));
assert(!hasIndirections!S);
assert( hasIndirections!T);
```


More information about the Digitalmars-d-learn mailing list