mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-29 05:27:43 +00:00
[Build]Compatibility with VS17.3 and later, for C++23 <expected>(#37321)
[Build] compatibility with VS17.3 and later, for C++23 <expected> has been introduced in VS17.3.6, and std::expected has conflict/inconsistent with the makeshift (expected-lite)
This commit is contained in:
parent
33ec492389
commit
cc644b1998
@ -82,12 +82,20 @@ namespace updating
|
|||||||
// prevent the warning that may show up depend on the value of the constants (#defines)
|
// prevent the warning that may show up depend on the value of the constants (#defines)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4702)
|
#pragma warning(disable : 4702)
|
||||||
|
#if USE_STD_EXPECTED
|
||||||
|
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||||
|
#else
|
||||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
||||||
if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0)
|
if constexpr (VERSION_MAJOR == 0 && VERSION_MINOR == 0)
|
||||||
{
|
{
|
||||||
|
#if USE_STD_EXPECTED
|
||||||
|
co_return std::unexpected(LOCAL_BUILD_ERROR);
|
||||||
|
#else
|
||||||
co_return nonstd::make_unexpected(LOCAL_BUILD_ERROR);
|
co_return nonstd::make_unexpected(LOCAL_BUILD_ERROR);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -139,7 +147,11 @@ namespace updating
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#if USE_STD_EXPECTED
|
||||||
|
co_return std::unexpected(NETWORK_ERROR);
|
||||||
|
#else
|
||||||
co_return nonstd::make_unexpected(NETWORK_ERROR);
|
co_return nonstd::make_unexpected(NETWORK_ERROR);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
@ -6,7 +6,14 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <winrt/Windows.Foundation.h>
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
//#if __MSVC_VERSION__ >= 1933 // MSVC begin to support std::unexpected in 19.33
|
||||||
|
#if __has_include(<expected> ) // use the same way with excepted-lite to detect std::unexcepted, as using it as backup
|
||||||
|
#include <expected>
|
||||||
|
#define USE_STD_EXPECTED 1
|
||||||
|
#else
|
||||||
#include <expected.hpp>
|
#include <expected.hpp>
|
||||||
|
#define USE_STD_EXPECTED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <common/version/helper.h>
|
#include <common/version/helper.h>
|
||||||
|
|
||||||
@ -27,7 +34,11 @@ namespace updating
|
|||||||
|
|
||||||
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version);
|
std::future<std::optional<std::filesystem::path>> download_new_version(const new_version_download_info& new_version);
|
||||||
std::filesystem::path get_pending_updates_path();
|
std::filesystem::path get_pending_updates_path();
|
||||||
|
#if USE_STD_EXPECTED
|
||||||
|
std::future<std::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||||
|
#else
|
||||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease = false);
|
||||||
|
#endif
|
||||||
void cleanup_updates();
|
void cleanup_updates();
|
||||||
|
|
||||||
// non-localized
|
// non-localized
|
||||||
|
Loading…
x
Reference in New Issue
Block a user