diff options
Diffstat (limited to 'include/fud_string_view.hpp')
-rw-r--r-- | include/fud_string_view.hpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/fud_string_view.hpp b/include/fud_string_view.hpp index 6403c27..327bf20 100644 --- a/include/fud_string_view.hpp +++ b/include/fud_string_view.hpp @@ -68,10 +68,10 @@ struct StringView { explicit StringView(const String& fudString) noexcept; template <size_t N> - constexpr static StringView cStringView(const char (&input)[N]) + constexpr static StringView makeFromCString(const char (&input)[N]) { static_assert(N > 0); - return StringView{N, reinterpret_cast<const utf8*>(input)}; + return StringView{N - 1, reinterpret_cast<const utf8*>(input)}; } [[nodiscard]] constexpr size_t length() const @@ -84,6 +84,11 @@ struct StringView { return m_data; } + [[nodiscard]] inline const char* c_str() const + { + return reinterpret_cast<const char*>(m_data); + } + constexpr const utf8& operator[](size_t index) const { if constexpr (fudBoundsChecking) { |