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 334d6c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/enum_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ 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;
}

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

0 comments on commit 334d6c8

Please sign in to comment.