Skip to content

Commit

Permalink
add compare for string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
mguludag committed Mar 12, 2024
1 parent 1594c45 commit e37c31f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/enum_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ class basic_string_view {
return (lhs.size_ == rhs.size_) && std::strncmp(lhs.data_, rhs.data_, lhs.size_) == 0;
}

constexpr friend inline bool
operator==(basic_string_view<Char> lhs, const Char* rhs) noexcept
{
return (lhs.size_ == strlen_constexpr(rhs)) && std::strncmp(lhs.data_, rhs, lhs.size_) == 0;
}

constexpr friend inline bool
operator!=(basic_string_view<Char> lhs, basic_string_view<Char> rhs) noexcept
{
return !(lhs == rhs);
}

constexpr friend inline bool
operator!=(basic_string_view<Char> lhs, const Char* rhs) noexcept
{
return !(lhs == rhs);
}

inline operator std::string()
{
return std::string(data_, size_);
Expand Down

0 comments on commit e37c31f

Please sign in to comment.