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 rs 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(r[0].length, r[1].length, ...)) evaluations of pred.

Tuple!Ranges mismatch(alias pred, Ranges...) (
  Ranges rs
)
if (rs.length >= 2 && allSatisfy!(isInputRange, Ranges));

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 .. $]

auto m2 = mismatch(x[], y[], x[], y[]);
writeln(m2[0]); // x[3 .. $]
writeln(m2[1]); // y[3 .. $]
writeln(m2[2]); // x[3 .. $]
writeln(m2[3]); // y[3 .. $]

Authors

Andrei Alexandrescu

License

Boost License 1.0.