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.

Function std.typecons.Tuple.opCmp

Comparison for ordering.

auto opCmp(R) (
  R rhs
)
if (areCompatibleTuples!(typeof(this), R, "<"));

auto opCmp(R) (
  R rhs
) const
if (areCompatibleTuples!(typeof(this), R, "<"));

Parameters

NameDescription
rhs The Tuple to compare against. It must meet the criteria for comparison between Tuples.

Returns

For any values v1 contained by the left-hand side tuple and any values v2 contained by the right-hand side:

0 if v1 == v2 for all members or the following value for the first position were the mentioned criteria is not satisfied:

  • NaN, in case one of the operands is a NaN.
  • A negative number if the expression v1 < v2 is true.
  • A positive number if the expression v1 > v2 is true.

Example

The first v1 for which v1 > v2 is true determines the result. This could lead to unexpected behaviour.

auto tup1 = tuple(1, 1, 1);
auto tup2 = tuple(1, 100, 100);
assert(tup1 < tup2);

//Only the first result matters for comparison
tup1[0] = 2;
assert(tup1 > tup2);

Authors

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

License

Boost License 1.0.