Skip to content

Commit fa3d930

Browse files
author
MarcoFalke
committed
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.
1 parent fa00098 commit fa3d930

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/util/fs.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ class path : public std::filesystem::path
5656

5757
std::string u8string() const
5858
{
59-
const auto& utf8_str{std::filesystem::path::u8string()};
60-
// utf8_str might either be std::string (C++17) or std::u8string
61-
// (C++20). Convert both to std::string. This method can be removed
62-
// after switching to C++20.
59+
const std::u8string& utf8_str{std::filesystem::path::u8string()};
60+
// Convert to std::string as a convenience for use in RPC code.
6361
return std::string{utf8_str.begin(), utf8_str.end()};
6462
}
6563

@@ -71,11 +69,7 @@ class path : public std::filesystem::path
7169

7270
static inline path u8path(const std::string& utf8_str)
7371
{
74-
#if __cplusplus < 202002L
75-
return std::filesystem::u8path(utf8_str);
76-
#else
7772
return std::filesystem::path(std::u8string{utf8_str.begin(), utf8_str.end()});
78-
#endif
7973
}
8074

8175
// Disallow implicit std::string conversion for absolute to avoid

0 commit comments

Comments
 (0)