View source code
Display the source code in std/algorithm/comparison.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.algorithm.comparison.equal.equal

Compares two ranges for equality. The ranges may have different element types, as long as pred(r1.front, r2.front) evaluates to bool. Performs Ο(min(r1.length, r2.length)) evaluations of pred.

bool equal(Range1, Range2) (
  Range1 r1,
  Range2 r2
)
if (isInputRange!Range1 && isInputRange!Range2 && !(isInfinite!Range1 && isInfinite!Range2) && is(typeof(binaryFun!pred(r1.front, r2.front))));

At least one of the ranges must be finite. If one range involved is infinite, the result is (statically known to be) false.

If the two ranges are different kinds of UTF code unit (char, wchar, or dchar), then the arrays are compared using UTF decoding to avoid accidentally integer-promoting units.

Parameters

NameDescription
r1 The first range to be compared.
r2 The second range to be compared.

Returns

true if and only if the two ranges compare equal element for element, according to binary predicate pred.

Authors

Andrei Alexandrescu

License

Boost License 1.0.