From fda1280d2993cfca9b187b67b8de5067d07604c5 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 2 May 2024 22:20:25 -0500 Subject: [PATCH] [ox/std] Make substr always take and return a StringView --- deps/ox/src/ox/std/strops.hpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/deps/ox/src/ox/std/strops.hpp b/deps/ox/src/ox/std/strops.hpp index afb650f5..25acc74d 100644 --- a/deps/ox/src/ox/std/strops.hpp +++ b/deps/ox/src/ox/std/strops.hpp @@ -14,26 +14,23 @@ #include "stringview.hpp" #include "types.hpp" #include "vector.hpp" -#include "writer.hpp" namespace ox { -template [[nodiscard]] -constexpr Str substr(Str const&str, std::size_t pos) noexcept { +constexpr ox::StringView substr(ox::StringView const&str, std::size_t pos) noexcept { if (str.len() >= pos) { - return Str(str.data() + pos, str.len() - pos); + return {str.data() + pos, str.len() - pos}; } - return Str(); + return {}; } -template [[nodiscard]] -constexpr ox::StringView substr(Str const&str, std::size_t start, std::size_t end) noexcept { +constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std::size_t end) noexcept { if (str.len() >= start && end >= start) { - return Str(str.data() + start, end - start); + return {str.data() + start, end - start}; } - return Str(); + return {}; } template