Skip to content

Commit 18ed74e

Browse files
author
Richard Musil
committed
Experimental: Changing C++ standard detection logic to accommodate potential corner cases.
Signed-off-by: Richard Musil <[email protected]>
1 parent 144f340 commit 18ed74e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/nlohmann/detail/macro_scope.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,20 @@
3232

3333
// C++ language standard detection
3434
// if the user manually specified the used c++ version this is skipped
35-
#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
36-
#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
35+
#if !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
36+
#if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
37+
#define JSON_HAS_CPP_23
3738
#define JSON_HAS_CPP_20
3839
#define JSON_HAS_CPP_17
3940
#define JSON_HAS_CPP_14
40-
#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
41+
#elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
42+
#define JSON_HAS_CPP_20
43+
#define JSON_HAS_CPP_17
44+
#define JSON_HAS_CPP_14
45+
#elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
4146
#define JSON_HAS_CPP_17
4247
#define JSON_HAS_CPP_14
43-
#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
48+
#elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
4449
#define JSON_HAS_CPP_14
4550
#endif
4651
// the cpp 11 flag is always specified because it is the minimal required version

include/nlohmann/detail/macro_unscope.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#undef JSON_HAS_CPP_14
3535
#undef JSON_HAS_CPP_17
3636
#undef JSON_HAS_CPP_20
37+
#undef JSON_HAS_CPP_23
3738
#undef JSON_HAS_FILESYSTEM
3839
#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
3940
#undef JSON_HAS_THREE_WAY_COMPARISON

0 commit comments

Comments
 (0)