Use built-in tuple operations

This commit is contained in:
k-hara 2013-05-27 11:05:13 +09:00
parent eadb9f928c
commit 292b23b51c

View file

@ -409,10 +409,7 @@ template Tuple(Specs...)
*/ */
this()(Types values) this()(Types values)
{ {
foreach (i, _; Types) field[] = values[];
{
field[i] = values[i];
}
} }
/** /**
@ -443,10 +440,7 @@ template Tuple(Specs...)
this(U)(U another) this(U)(U another)
if (areCompatibleTuples!(typeof(this), U, "=")) if (areCompatibleTuples!(typeof(this), U, "="))
{ {
foreach (i, T; Types) field[] = another.field[];
{
field[i] = another.field[i];
}
} }
/** /**
@ -455,21 +449,13 @@ template Tuple(Specs...)
bool opEquals(R)(R rhs) bool opEquals(R)(R rhs)
if (areCompatibleTuples!(typeof(this), R, "==")) if (areCompatibleTuples!(typeof(this), R, "=="))
{ {
foreach (i, Unused; Types) return field[] == rhs.field[];
{
if (field[i] != rhs.field[i]) return false;
}
return true;
} }
/// ditto /// ditto
bool opEquals(R)(R rhs) const bool opEquals(R)(R rhs) const
if (areCompatibleTuples!(typeof(this), R, "==")) if (areCompatibleTuples!(typeof(this), R, "=="))
{ {
foreach (i, Unused; Types) return field[] == rhs.field[];
{
if (field[i] != rhs.field[i]) return false;
}
return true;
} }
/** /**
@ -509,10 +495,7 @@ template Tuple(Specs...)
if (areCompatibleTuples!(typeof(this), R, "=")) if (areCompatibleTuples!(typeof(this), R, "="))
{ {
// Do not swap; opAssign should be called on the fields. // Do not swap; opAssign should be called on the fields.
foreach (i, Unused; Types) field[] = rhs.field[];
{
field[i] = rhs.field[i];
}
} }
/** /**