Skip to content

Commit 0f23920

Browse files
committed
partial bitcoin#24169: Add --enable-c++20 option
excludes: - fae6790
1 parent a3b7926 commit 0f23920

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

configure.ac

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ AC_ARG_ENABLE([c++20],
7272
[use_cxx20=$enableval],
7373
[use_cxx20=no])
7474

75-
dnl Require C++17 or C++20 compiler (no GNU extensions)
76-
if test "x$use_cxx20" = xyes; then
77-
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
78-
else
75+
dnl Require C++17 compiler (no GNU extensions)
76+
if test "$use_cxx20" = "no"; then
7977
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
78+
else
79+
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
8080
fi
8181

8282
dnl Check if -latomic is required for <std::atomic>

src/fs.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,26 @@ class path : public std::filesystem::path
5151
// Disallow std::string conversion method to avoid locale-dependent encoding on windows.
5252
std::string string() const = delete;
5353

54+
std::string u8string() const
55+
{
56+
const auto& utf8_str{std::filesystem::path::u8string()};
57+
// utf8_str might either be std::string (C++17) or std::u8string
58+
// (C++20). Convert both to std::string. This method can be removed
59+
// after switching to C++20.
60+
return std::string{utf8_str.begin(), utf8_str.end()};
61+
}
62+
5463
// Required for path overloads in <fstream>.
5564
// See https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=96e0367ead5d8dcac3bec2865582e76e2fbab190
5665
path& make_preferred() { std::filesystem::path::make_preferred(); return *this; }
5766
path filename() const { return std::filesystem::path::filename(); }
5867
};
5968

69+
static inline path u8path(const std::string& utf8_str)
70+
{
71+
return std::filesystem::u8path(utf8_str);
72+
}
73+
6074
// Disallow implicit std::string conversion for absolute to avoid
6175
// locale-dependent encoding on windows.
6276
static inline path absolute(const path& p)
@@ -116,8 +130,8 @@ static inline std::string PathToString(const path& path)
116130
// use here, because these methods encode the path using C++'s narrow
117131
// multibyte encoding, which on Windows corresponds to the current "code
118132
// page", which is unpredictable and typically not able to represent all
119-
// valid paths. So std::filesystem::path::u8string() and
120-
// std::filesystem::u8path() functions are used instead on Windows. On
133+
// valid paths. So fs::path::u8string() and
134+
// fs::u8path() functions are used instead on Windows. On
121135
// POSIX, u8string/u8path functions are not safe to use because paths are
122136
// not always valid UTF-8, so plain string methods which do not transform
123137
// the path there are used.

src/scheduler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void Repeat(CScheduler& s, CScheduler::Function f, std::chrono::milliseco
109109

110110
void CScheduler::scheduleEvery(CScheduler::Function f, std::chrono::milliseconds delta)
111111
{
112-
scheduleFromNow([=] { Repeat(*this, f, delta); }, delta);
112+
scheduleFromNow([this, f, delta] { Repeat(*this, f, delta); }, delta);
113113
}
114114

115115
size_t CScheduler::getQueueInfo(std::chrono::system_clock::time_point& first,

0 commit comments

Comments
 (0)