mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
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.
This commit is contained in:
parent
fa00098e1a
commit
fa3d9304e8
1 changed files with 2 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue