From ff26f6435e9fbbfdaf9828e59521cd4c820ac0d6 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Fri, 5 Aug 2022 17:14:57 -0700 Subject: [PATCH 1/2] Use structured binding for pair values dir_path is used by PanicAlertFormatT, which prior to PR 10209 used a lambda. Before c++20, referring to structured bindings in lambda captures was forbidden. The problem is now doubly fixed, so put the structured binding back in. --- Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index 83263ed04d..5e012e44db 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -178,11 +178,7 @@ void CEXIMemoryCard::SetupGciFolder(const Memcard::HeaderData& header_data) current_game_id = Common::swap32(reinterpret_cast(game_id.c_str())); } - // TODO(C++20): Use structured bindings when we can use C++20 and refer to structured bindings - // in lambda captures - const auto folder_path_pair = GetGCIFolderPath(m_card_slot, AllowMovieFolder::Yes); - const std::string& dir_path = folder_path_pair.first; - const bool migrate = folder_path_pair.second; + const auto [dir_path, migrate] = GetGCIFolderPath(m_card_slot, AllowMovieFolder::Yes); const File::FileInfo file_info(dir_path); if (!file_info.Exists()) From 02cd4ecf7d8a3e9738acffd1c38c99ea5599d7ad Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Fri, 5 Aug 2022 17:31:25 -0700 Subject: [PATCH 2/2] Core: Use std::chrono time_since_epoch --- Source/Core/Core/State.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index d4abf52bcd..a6467f2b2c 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -276,14 +276,7 @@ static constexpr int DOUBLE_TIME_OFFSET = (38 * 365 * 24 * 60 * 60); static double GetSystemTimeAsDouble() { - // FYI: std::chrono::system_clock epoch is not required to be 1970 until c++20. - // We will however assume time_t IS unix time. - using Clock = std::chrono::system_clock; - - // TODO: Use this on switch to c++20: - // const auto since_epoch = Clock::now().time_since_epoch(); - const auto unix_epoch = Clock::from_time_t({}); - const auto since_epoch = Clock::now() - unix_epoch; + const auto since_epoch = std::chrono::system_clock::now().time_since_epoch(); const auto since_double_time_epoch = since_epoch - std::chrono::seconds(DOUBLE_TIME_OFFSET); return std::chrono::duration_cast>(since_double_time_epoch).count();