fix: use new way to detect c++ version in MSVC.
- use new macro to check C++ version in MSVC, instead of use compiler switch and __cplusplus macro.
This commit is contained in:
parent
f3a88e951c
commit
3858b4f3ec
|
@ -72,10 +72,6 @@ PRIVATE
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
||||||
)
|
)
|
||||||
target_compile_options(YYCCommonplace
|
target_compile_options(YYCCommonplace
|
||||||
# Enable new __cplusplus macro in MSVC.
|
|
||||||
# Because we use it in header, so we need populate it.
|
|
||||||
PUBLIC
|
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>
|
|
||||||
# Order build as UTF-8 in MSVC
|
# Order build as UTF-8 in MSVC
|
||||||
PRIVATE
|
PRIVATE
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
||||||
|
|
|
@ -204,10 +204,12 @@ namespace YYCC::StdPatch {
|
||||||
*/
|
*/
|
||||||
template<class _TContainer, class _TKey>
|
template<class _TContainer, class _TKey>
|
||||||
bool Contains(const _TContainer& container, const _TKey& key) {
|
bool Contains(const _TContainer& container, const _TKey& key) {
|
||||||
#if __cplusplus < 202002L
|
// __cplusplus macro need special compiler switch enabled when compiling.
|
||||||
return container.find(key) != container.end();
|
// So we use _MSVC_LANG check it instead.
|
||||||
#else
|
#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||||
return container.contains(key);
|
return container.contains(key);
|
||||||
|
#else
|
||||||
|
return container.find(key) != container.end();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user