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.mismatch

Sequentially compares elements in r1 and r2 in lockstep, and stops at the first mismatch (according to pred, by default equality). Returns a tuple with the reduced ranges that start with the two mismatched values. Performs Ο(min(r1.length, r2.length)) evaluations of pred.

Tuple!(Range1,Range2) mismatch(alias pred, Range1, Range2) (
  Range1 r1,
  Range2 r2
)
if (isInputRange!Range1 && isInputRange!Range2);

Example

int[6] x = [ 1,   5, 2, 7,   4, 3 ];
double[6] y = [ 1.0, 5, 2, 7.3, 4, 8 ];
auto m = mismatch(x[], y[]);
writeln(m[0]); // x[3 .. $]
writeln(m[1]); // y[3 .. $]

Authors

Andrei Alexandrescu

License

Boost License 1.0.