From b13eb0ef70df6b63a278dd8c3b2ccb9b253c4777 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 3 Dec 2023 10:17:24 -0600 Subject: [PATCH] [ox/fs] Make FileAddress constructor take a StringLiteral --- deps/ox/src/ox/fs/filesystem/filelocation.hpp | 6 +++--- deps/ox/src/ox/std/stringliteral.hpp | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.hpp b/deps/ox/src/ox/fs/filesystem/filelocation.hpp index 2d512e31..c5f026b0 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.hpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.hpp @@ -65,7 +65,7 @@ class FileAddress { explicit FileAddress(char *path) noexcept; - explicit constexpr FileAddress(const char *path) noexcept; + constexpr FileAddress(ox::StringLiteral path) noexcept; constexpr ~FileAddress() noexcept; @@ -124,8 +124,8 @@ class FileAddress { }; -constexpr FileAddress::FileAddress(const char *path) noexcept { - m_data.constPath = path; +constexpr FileAddress::FileAddress(ox::StringLiteral path) noexcept { + m_data.constPath = path.c_str(); m_type = FileAddressType::ConstPath; } diff --git a/deps/ox/src/ox/std/stringliteral.hpp b/deps/ox/src/ox/std/stringliteral.hpp index f6566221..f777b5af 100644 --- a/deps/ox/src/ox/std/stringliteral.hpp +++ b/deps/ox/src/ox/std/stringliteral.hpp @@ -41,6 +41,10 @@ class StringLiteral: public detail::BaseStringView { return *this; } + [[nodiscard]] + constexpr const char *c_str() const noexcept { + return data(); + } };