mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Merge opOpAssign overloads
Also avoids private symbols in RefAppender constraint.
This commit is contained in:
parent
b7906549c5
commit
277fe1997b
1 changed files with 12 additions and 36 deletions
48
std/array.d
48
std/array.d
|
@ -2921,25 +2921,14 @@ if (isDynamicArray!A)
|
|||
}
|
||||
|
||||
/**
|
||||
* Appends `item` to the managed array.
|
||||
* Appends `rhs` to the managed array.
|
||||
* Params:
|
||||
* rhs = Element or range.
|
||||
*/
|
||||
void opOpAssign(string op : "~", U)(U item) if (canPutItem!U)
|
||||
void opOpAssign(string op : "~", U)(U rhs)
|
||||
if (__traits(compiles, put(rhs)))
|
||||
{
|
||||
put(item);
|
||||
}
|
||||
|
||||
// Const fixing hack.
|
||||
void opOpAssign(string op : "~", Range)(Range items) if (canPutConstRange!Range)
|
||||
{
|
||||
put(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an entire range to the managed array.
|
||||
*/
|
||||
void opOpAssign(string op : "~", Range)(Range items) if (canPutRange!Range)
|
||||
{
|
||||
put(items);
|
||||
put(rhs);
|
||||
}
|
||||
|
||||
// only allow overwriting data on non-immutable and non-const data
|
||||
|
@ -3083,28 +3072,15 @@ if (isDynamicArray!A)
|
|||
}
|
||||
|
||||
/**
|
||||
* Appends `item` to the managed array.
|
||||
* Appends `rhs` to the managed array.
|
||||
* Params:
|
||||
* rhs = Element or range.
|
||||
*/
|
||||
void opOpAssign(string op : "~", U)(U item) if (Appender!A.canPutItem!U)
|
||||
void opOpAssign(string op : "~", U)(U rhs)
|
||||
if (__traits(compiles, (Appender!A a){ a.put(rhs); }))
|
||||
{
|
||||
scope(exit) *this.arr = impl.data;
|
||||
impl.put(item);
|
||||
}
|
||||
|
||||
// Const fixing hack.
|
||||
void opOpAssign(string op : "~", Range)(Range items) if (Appender!A.canPutConstRange!Range)
|
||||
{
|
||||
scope(exit) *this.arr = impl.data;
|
||||
impl.put(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an entire range to the managed array.
|
||||
*/
|
||||
void opOpAssign(string op : "~", Range)(Range items) if (Appender!A.canPutRange!Range)
|
||||
{
|
||||
scope(exit) *this.arr = impl.data;
|
||||
impl.put(items);
|
||||
impl.put(rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue