diff --git a/include/stdex/compat.hpp b/include/stdex/compat.hpp index c73266921..961555d69 100644 --- a/include/stdex/compat.hpp +++ b/include/stdex/compat.hpp @@ -162,6 +162,12 @@ #endif #endif +#if _HAS_CXX17 +#define _Constexpr_ constexpr +#else +#define _Constexpr_ +#endif + #ifdef _MSC_VER #define _Deprecated_(message) __declspec(deprecated(message)) #else diff --git a/include/stdex/unicode.hpp b/include/stdex/unicode.hpp index 369592fb9..31f2ec58e 100644 --- a/include/stdex/unicode.hpp +++ b/include/stdex/unicode.hpp @@ -101,7 +101,7 @@ namespace stdex return; } - if constexpr (sizeof(T_from) == sizeof(char) && sizeof(T_to) == sizeof(wchar_t)) { + if _Constexpr_ (sizeof(T_from) == sizeof(char) && sizeof(T_to) == sizeof(wchar_t)) { assert(count_src < INT_MAX || count_src == SIZE_MAX); // Try to convert to stack buffer first. @@ -124,7 +124,7 @@ namespace stdex throw std::runtime_error("MultiByteToWideChar failed"); } - if constexpr (sizeof(T_from) == sizeof(wchar_t) && sizeof(T_to) == sizeof(char)) { + if _Constexpr_ (sizeof(T_from) == sizeof(wchar_t) && sizeof(T_to) == sizeof(char)) { assert(count_src < INT_MAX || count_src == SIZE_MAX); // Try to convert to stack buffer first. @@ -147,7 +147,7 @@ namespace stdex throw std::runtime_error("WideCharToMultiByte failed"); } - if constexpr (sizeof(T_from) == sizeof(char) && sizeof(T_to) == sizeof(char)) { + if _Constexpr_ (sizeof(T_from) == sizeof(char) && sizeof(T_to) == sizeof(char)) { assert(count_src < INT_MAX || count_src == SIZE_MAX); // Try to convert to stack buffer first.