| 446 | } |
| 447 | |
| 448 | bool AlmostEqual(std::string const & str1, std::string const & str2, size_t mismatchedCount) |
| 449 | { |
| 450 | std::pair mis(str1.begin(), str2.begin()); |
| 451 | auto const str1End = str1.end(); |
| 452 | auto const str2End = str2.end(); |
| 453 | |
| 454 | for (size_t i = 0; i <= mismatchedCount; ++i) |
| 455 | { |
| 456 | auto const end = mis.first + std::min(distance(mis.first, str1End), distance(mis.second, str2End)); |
| 457 | mis = mismatch(mis.first, end, mis.second); |
| 458 | if (mis.first == str1End && mis.second == str2End) |
| 459 | return true; |
| 460 | if (mis.first != str1End) |
| 461 | ++mis.first; |
| 462 | if (mis.second != str2End) |
| 463 | ++mis.second; |
| 464 | } |
| 465 | return false; |
| 466 | } |
| 467 | |
| 468 | namespace |
| 469 | { |