From 2522b1ef455214944317b526c25655bd2924ca2c Mon Sep 17 00:00:00 2001 From: halx99 Date: Tue, 3 Jan 2023 18:01:40 +0800 Subject: [PATCH] Fix feature check for MSVC --- core/base/ccUtils.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/base/ccUtils.cpp b/core/base/ccUtils.cpp index a4a0659a70..6a931dcd83 100644 --- a/core/base/ccUtils.cpp +++ b/core/base/ccUtils.cpp @@ -801,7 +801,15 @@ AX_DLL std::string base64Encode(std::string_view s) if (n > 0) { std::string ret; -#if defined(_HAS_CXX23) && _HAS_CXX23 + /** + * @brief resize_and_overrite avaialbe on vs2022 17.1 + * refer to: + * - https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170 + * - https://github.com/microsoft/STL/wiki/Changelog#vs-2022-171 + * - https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 + * + */ +#if defined(_HAS_CXX23) && _HAS_CXX23 && (_MSC_VER >= 1931) ret.resize_and_overwrite(n, [&](char* p, size_t) { return ax::base64::encode(p, s.data(), s.length()); }); #else ret.resize(n); @@ -820,7 +828,7 @@ AX_DLL std::string base64Decode(std::string_view s) { std::string ret; -#if defined(_HAS_CXX23) && _HAS_CXX23 +#if defined(_HAS_CXX23) && _HAS_CXX23 && (_MSC_VER >= 1931) ret.resize_and_overwrite(n, [&](char* p, size_t) { return ax::base64::decode(p, s.data(), s.length()); }); #else ret.resize(n);