| 53 | // Special case for strings, to allow for insensitive case comparisons for std::string matchers. |
| 54 | template <> |
| 55 | bool |
| 56 | Matchers<std::string>::test_eq(const std::string &t) const |
| 57 | { |
| 58 | bool r = false; |
| 59 | |
| 60 | if (_data.length() == t.length()) { |
| 61 | if (_nocase) { |
| 62 | // ToDo: in C++20, this would be nicer with std::range, e.g. |
| 63 | // r = std::ranges::equal(_data, t, [](char c1, char c2) { return std::tolower(c1) == std::tolower(c2); }); |
| 64 | r = std::equal(_data.begin(), _data.end(), t.begin(), [](char c1, char c2) { |
| 65 | return std::tolower(static_cast<unsigned char>(c1)) == std::tolower(static_cast<unsigned char>(c2)); |
| 66 | }); |
| 67 | } else { |
| 68 | r = (t == _data); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if (pi_dbg_ctl.on()) { |
| 73 | debug_helper(t, " == ", r); |
| 74 | } |
| 75 | |
| 76 | return r; |
| 77 | } |