From 292b23b51c6fac5ec0c5ae40a6634973f807949d Mon Sep 17 00:00:00 2001 From: k-hara Date: Mon, 27 May 2013 11:05:13 +0900 Subject: [PATCH] Use built-in tuple operations --- std/typecons.d | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/std/typecons.d b/std/typecons.d index 454372dd3..1b20cbe9b 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -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[]; } /**