View source code
Display the source code in std/typecons.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

std.typecons.Tuple.this - multiple declarations

Function Tuple.this

Constructor taking one value for each field.

this (
  Tuple.Types values
);

Parameters

NameDescription
values A list of values that are either the same types as those given by the Types field of this Tuple, or can implicitly convert to those types. They must be in the same order as they appear in Types.

Example

alias ISD = Tuple!(int, string, double);
auto tup = ISD(1, "test", 3.2);
writeln(tup.toString()); // `Tuple!(int, string, double)(1, "test", 3.2)`

Function Tuple.this

Constructor taking a compatible array.

this(U, size_t n) (
  U[n] values
)
if (n == Types.length && allSatisfy!(isBuildableFrom!U, Types));

Parameters

NameDescription
values A compatible static array to build the Tuple from. Array slices are not supported.

Example

int[2] ints;
Tuple!(int, int) t = ints;

Function Tuple.this

Constructor taking a compatible Tuple. Two Tuples are compatible iff they are both of the same length, and, for each type T on the left-hand side, the corresponding type U on the right-hand side can implicitly convert to T.

this(U) (
  U another
)
if (areBuildCompatibleTuples!(typeof(this), U));

Parameters

NameDescription
another A compatible Tuple to build from. Its type must be compatible with the target Tuple's type.

Example

alias IntVec = Tuple!(int, int, int);
alias DubVec = Tuple!(double, double, double);

IntVec iv = tuple(1, 1, 1);

//Ok, int can implicitly convert to double
DubVec dv = iv;
//Error: double cannot implicitly convert to int
//IntVec iv2 = dv;

Authors

Andrei Alexandrescu, Bartosz Milewski, Don Clugston, Shin Fujishiro, Kenji Hara

License

Boost License 1.0.