iless.h 371 B

12345678910111213141516
  1. #pragma once
  2. #include <_strings.h>
  3. #include <string_view>
  4. namespace abnf::detail {
  5. struct iless {
  6. using is_transparent = void;
  7. bool operator()(std::string_view lhs, std::string_view rhs) const {
  8. int const cmp =
  9. strncasecmp(lhs.data(), rhs.data(), std::min(lhs.size(), rhs.size()));
  10. return cmp < 0 || (cmp == 0 && lhs.size() < rhs.size());
  11. }
  12. };
  13. }