diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dbcf12d..b050eac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,10 +72,6 @@ PRIVATE $<$:_UNICODE> ) target_compile_options(YYCCommonplace -# Enable new __cplusplus macro in MSVC. -# Because we use it in header, so we need populate it. -PUBLIC - $<$:/Zc:__cplusplus> # Order build as UTF-8 in MSVC PRIVATE $<$:/utf-8> diff --git a/src/StdPatch.hpp b/src/StdPatch.hpp index 1cfddf0..69388e1 100644 --- a/src/StdPatch.hpp +++ b/src/StdPatch.hpp @@ -204,10 +204,12 @@ namespace YYCC::StdPatch { */ template bool Contains(const _TContainer& container, const _TKey& key) { -#if __cplusplus < 202002L - return container.find(key) != container.end(); -#else + // __cplusplus macro need special compiler switch enabled when compiling. + // So we use _MSVC_LANG check it instead. +#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) return container.contains(key); +#else + return container.find(key) != container.end(); #endif }