From fa3d9304e80c214c8b073f12a7f4b08c5a94af04 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Sat, 9 Dec 2023 13:00:45 +0100 Subject: [PATCH] refactor: Remove pre-C++20 fs code Treating std::string as UTF-8 is deprecated in std::filesystem::path since C++20. However, it makes this codebase easier to read and maintain to retain the ability for std::string to hold UTF-8. --- src/util/fs.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/util/fs.h b/src/util/fs.h index 3e69a540d23..4eee97c3380 100644 --- a/src/util/fs.h +++ b/src/util/fs.h @@ -56,10 +56,8 @@ public: std::string u8string() const { - const auto& utf8_str{std::filesystem::path::u8string()}; - // utf8_str might either be std::string (C++17) or std::u8string - // (C++20). Convert both to std::string. This method can be removed - // after switching to C++20. + const std::u8string& utf8_str{std::filesystem::path::u8string()}; + // Convert to std::string as a convenience for use in RPC code. return std::string{utf8_str.begin(), utf8_str.end()}; } @@ -71,11 +69,7 @@ public: static inline path u8path(const std::string& utf8_str) { -#if __cplusplus < 202002L - return std::filesystem::u8path(utf8_str); -#else return std::filesystem::path(std::u8string{utf8_str.begin(), utf8_str.end()}); -#endif } // Disallow implicit std::string conversion for absolute to avoid