From 334d6c808adf5a6747454b02a3c6794e85f1a3dd Mon Sep 17 00:00:00 2001 From: "M. Galib Uludag" Date: Tue, 12 Mar 2024 16:10:02 +0000 Subject: [PATCH] add compare for string_view --- include/enum_name.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/enum_name.hpp b/include/enum_name.hpp index 7be2bfb..76ecd60 100644 --- a/include/enum_name.hpp +++ b/include/enum_name.hpp @@ -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 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_);