|
32 | 32 | #endif
|
33 | 33 | #endif
|
34 | 34 |
|
| 35 | +// included here for _HAS_CXX* macros |
| 36 | +#include <zmq.h> |
| 37 | + |
| 38 | +#if defined(_MSVC_LANG) |
| 39 | +#define CPPZMQ_LANG _MSVC_LANG |
| 40 | +#else |
| 41 | +#define CPPZMQ_LANG __cplusplus |
| 42 | +#endif |
| 43 | +// overwrite if specific language macros indicate higher version |
| 44 | +#if defined(_HAS_CXX14) && _HAS_CXX14 && CPPZMQ_LANG < 201402L |
| 45 | +#undef CPPZMQ_LANG |
| 46 | +#define CPPZMQ_LANG 201402L |
| 47 | +#endif |
| 48 | +#if defined(_HAS_CXX17) && _HAS_CXX17 && CPPZMQ_LANG < 201703L |
| 49 | +#undef CPPZMQ_LANG |
| 50 | +#define CPPZMQ_LANG 201703L |
| 51 | +#endif |
| 52 | + |
35 | 53 | // macros defined if has a specific standard or greater
|
36 |
| -#if (defined(__cplusplus) && __cplusplus >= 201103L) \ |
37 |
| - || (defined(_MSC_VER) && _MSC_VER >= 1900) |
| 54 | +#if CPPZMQ_LANG >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) |
38 | 55 | #define ZMQ_CPP11
|
39 | 56 | #endif
|
40 |
| -#if (defined(__cplusplus) && __cplusplus >= 201402L) \ |
41 |
| - || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) \ |
42 |
| - || (defined(_HAS_CXX17) \ |
43 |
| - && _HAS_CXX17 \ |
44 |
| - == 1) // _HAS_CXX14 might not be defined when using C++17 on MSVC |
| 57 | +#if CPPZMQ_LANG >= 201402L |
45 | 58 | #define ZMQ_CPP14
|
46 | 59 | #endif
|
47 |
| -#if (defined(__cplusplus) && __cplusplus >= 201703L) \ |
48 |
| - || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) |
| 60 | +#if CPPZMQ_LANG >= 201703L |
49 | 61 | #define ZMQ_CPP17
|
50 | 62 | #endif
|
51 | 63 |
|
|
80 | 92 | #define ZMQ_CONSTEXPR_VAR const
|
81 | 93 | #define ZMQ_CPP11_DEPRECATED(msg)
|
82 | 94 | #endif
|
| 95 | +#if defined(ZMQ_CPP14) && (!defined(_MSC_VER) || _MSC_VER > 1900) |
| 96 | +#define ZMQ_EXTENDED_CONSTEXPR |
| 97 | +#endif |
83 | 98 | #if defined(ZMQ_CPP17)
|
84 | 99 | #define ZMQ_INLINE_VAR inline
|
85 | 100 | #else
|
86 | 101 | #define ZMQ_INLINE_VAR
|
87 | 102 | #endif
|
88 | 103 |
|
89 |
| -#include <zmq.h> |
90 |
| - |
91 | 104 | #include <cassert>
|
92 | 105 | #include <cstring>
|
93 | 106 |
|
@@ -1004,7 +1017,7 @@ class mutable_buffer
|
1004 | 1017 | constexpr mutable_buffer() noexcept : _data(nullptr), _size(0) {}
|
1005 | 1018 | constexpr mutable_buffer(void *p, size_t n) noexcept : _data(p), _size(n)
|
1006 | 1019 | {
|
1007 |
| -#ifdef ZMQ_CPP14 |
| 1020 | +#ifdef ZMQ_EXTENDED_CONSTEXPR |
1008 | 1021 | assert(p != nullptr || n == 0);
|
1009 | 1022 | #endif
|
1010 | 1023 | }
|
@@ -1041,7 +1054,7 @@ class const_buffer
|
1041 | 1054 | constexpr const_buffer() noexcept : _data(nullptr), _size(0) {}
|
1042 | 1055 | constexpr const_buffer(const void *p, size_t n) noexcept : _data(p), _size(n)
|
1043 | 1056 | {
|
1044 |
| -#ifdef ZMQ_CPP14 |
| 1057 | +#ifdef ZMQ_EXTENDED_CONSTEXPR |
1045 | 1058 | assert(p != nullptr || n == 0);
|
1046 | 1059 | #endif
|
1047 | 1060 | }
|
@@ -1273,7 +1286,7 @@ template<class Char, size_t N>
|
1273 | 1286 | constexpr const_buffer str_buffer(const Char (&data)[N]) noexcept
|
1274 | 1287 | {
|
1275 | 1288 | static_assert(detail::is_pod_like<Char>::value, "Char must be POD");
|
1276 |
| -#ifdef ZMQ_CPP14 |
| 1289 | +#ifdef ZMQ_EXTENDED_CONSTEXPR |
1277 | 1290 | assert(data[N - 1] == Char{0});
|
1278 | 1291 | #endif
|
1279 | 1292 | return const_buffer(static_cast<const Char *>(data), (N - 1) * sizeof(Char));
|
|
0 commit comments