mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Use built-in tuple operations
This commit is contained in:
parent
eadb9f928c
commit
292b23b51c
1 changed files with 5 additions and 22 deletions
|
@ -409,10 +409,7 @@ template Tuple(Specs...)
|
|||
*/
|
||||
this()(Types values)
|
||||
{
|
||||
foreach (i, _; Types)
|
||||
{
|
||||
field[i] = values[i];
|
||||
}
|
||||
field[] = values[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,10 +440,7 @@ template Tuple(Specs...)
|
|||
this(U)(U another)
|
||||
if (areCompatibleTuples!(typeof(this), U, "="))
|
||||
{
|
||||
foreach (i, T; Types)
|
||||
{
|
||||
field[i] = another.field[i];
|
||||
}
|
||||
field[] = another.field[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -455,21 +449,13 @@ template Tuple(Specs...)
|
|||
bool opEquals(R)(R rhs)
|
||||
if (areCompatibleTuples!(typeof(this), R, "=="))
|
||||
{
|
||||
foreach (i, Unused; Types)
|
||||
{
|
||||
if (field[i] != rhs.field[i]) return false;
|
||||
}
|
||||
return true;
|
||||
return field[] == rhs.field[];
|
||||
}
|
||||
/// ditto
|
||||
bool opEquals(R)(R rhs) const
|
||||
if (areCompatibleTuples!(typeof(this), R, "=="))
|
||||
{
|
||||
foreach (i, Unused; Types)
|
||||
{
|
||||
if (field[i] != rhs.field[i]) return false;
|
||||
}
|
||||
return true;
|
||||
return field[] == rhs.field[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,10 +495,7 @@ template Tuple(Specs...)
|
|||
if (areCompatibleTuples!(typeof(this), R, "="))
|
||||
{
|
||||
// Do not swap; opAssign should be called on the fields.
|
||||
foreach (i, Unused; Types)
|
||||
{
|
||||
field[i] = rhs.field[i];
|
||||
}
|
||||
field[] = rhs.field[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue