Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/object.di
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,16 @@ version (unittest)
}
}
}

T[] dup(T)(const T[] a)
{
auto b = new T[a.length];
b[] = a[];
return b;
}

immutable(T)[] idup(T)(const T[] s)
{
return dup(s);
}

18 changes: 18 additions & 0 deletions src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -2754,3 +2754,21 @@ unittest
int[S[]] aa = [[S(11)] : 13];
assert(aa[[S(12)]] == 13); // fails
}

/************************
* Provide the .dup and .idup array properties.
*/
T[] dup(T)(const T[] a)
{
auto b = new T[a.length];
b[] = a[];
return b;
}

// ditto
immutable(T)[] idup(T)(const T[] s)
{
return dup(s);
}


3 changes: 2 additions & 1 deletion src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,8 @@ struct Array2


/**
*
* Replaced by object.dup and object.idup.
* Remove in 2.068.
*/
extern (C) void[] _adDupT(const TypeInfo ti, void[] a)
out (result)
Expand Down