Skip to content

Commit

Permalink
TextView: Add utility CaselessEqual functor.
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidWallOfCode committed Jul 13, 2023
1 parent e73e88f commit 2d3adc4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/include/swoc/TextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,12 @@ class TextView : public std::string_view {
}
};

/// Support for containers that need case insensitive comparisons between views.
struct CaselessEqual {
/// @return @c true if the strings are the same sans case.
/// @return @c true if the view contants are equal when compared without regard to case.
bool
operator()(self_type const& lhs, self_type const& rhs) const noexcept {

return lhs.size() == rhs.size() && 0 == strcasecmp(lhs, rhs);
}
};

Expand Down

0 comments on commit 2d3adc4

Please sign in to comment.