From e6205c67780f22e2de09b2058968b979eb5ba8db Mon Sep 17 00:00:00 2001 From: Rupert Nash Date: Fri, 15 Dec 2023 16:34:49 +0000 Subject: [PATCH] Use string_view for ct_string comparisons cos of better constexpr support --- Code/util/ct_string.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Code/util/ct_string.h b/Code/util/ct_string.h index e0ebe5377..a49998df6 100644 --- a/Code/util/ct_string.h +++ b/Code/util/ct_string.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace hemelb { @@ -33,6 +34,9 @@ namespace hemelb { constexpr std::string str() const { return {str_, N}; } + constexpr std::string_view view() const { + return {str_, N}; + } constexpr char const *c_str() const { return str_; @@ -45,12 +49,12 @@ namespace hemelb { template constexpr auto operator==(const ct_string& left, const ct_string& right) { - return left.str() == right.str(); + return left.view() == right.view(); } template constexpr auto operator==(const ct_string& left, const char* right) { - return left.str() == std::string{right}; + return left.view() == std::string_view{right}; } template constexpr auto operator==(const char* left, const ct_string right) {