string: simplify the lower/upper comparators
This commit is contained in:
parent
5666a64e77
commit
2e16e8962b
23
string.hpp
23
string.hpp
@ -228,14 +228,11 @@ namespace cruft::string::compare {
|
||||
/// \tparam TransformV A character transform function
|
||||
template <char (*TransformV)(char) noexcept>
|
||||
struct transform {
|
||||
template <
|
||||
typename CharT,
|
||||
typename = std::void_t<
|
||||
typename std::char_traits<CharT>::char_type
|
||||
>
|
||||
>
|
||||
bool operator() (cruft::view<CharT const *> a, cruft::view<CharT const*> b)
|
||||
{
|
||||
template <typename ContainerT>
|
||||
bool operator() (
|
||||
ContainerT const &a,
|
||||
ContainerT const &b
|
||||
) const noexcept {
|
||||
if (a.size () != b.size ())
|
||||
return false;
|
||||
|
||||
@ -255,15 +252,7 @@ namespace cruft::string::compare {
|
||||
>
|
||||
bool operator() (CharT const *a, CharT const *b) const noexcept
|
||||
{
|
||||
auto const *i = a;
|
||||
auto const *j = b;
|
||||
|
||||
for ( ; *i && *j; ++i, ++j)
|
||||
if (TransformV (*i) != TransformV (*j))
|
||||
return false;
|
||||
|
||||
// Ensure we've reached the ends of both strings
|
||||
return !*i && !*j;
|
||||
return (*this) (std::string_view (a), std::string_view (b));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user