From 1f032e3afdb57caed171b5cfdbc8579c7838ffc0 Mon Sep 17 00:00:00 2001 From: RealTimeChris <40668522+RealTimeChris@users.noreply.github.com> Date: Wed, 27 Nov 2024 07:41:08 -0500 Subject: [PATCH] Adding conditional_t for pre-CPP14. --- include/fast_float/ascii_number.h | 4 ++-- include/fast_float/float_common.h | 34 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index a70db6e..f5200f7 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -29,9 +29,9 @@ template fastfloat_really_inline constexpr bool has_simd_opt() { } template struct get_equal_sized_uint { - using type = std::conditional_t< + using type = FASTFLOAT_CONDITIONAL_T( sizeof(value_type) == 4, uint32_t, - std::conditional_t>; + FASTFLOAT_CONDITIONAL_T(sizeof(value_type) == 2, uint16_t, uint8_t)); }; template diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index ca1fd96..064e4b0 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -883,6 +883,40 @@ operator^=(chars_format &lhs, chars_format rhs) noexcept { return lhs = (lhs ^ rhs); } +#if defined(_MSC_VER) +#if _MSC_VER >= 1900 +#if _MSC_VER >= 1910 +#else +#define CPP14_NOT_SUPPORTED +#endif +#else +#define CPP14_NOT_SUPPORTED +#endif +#elif __cplusplus < 201402L +#define CPP14_NOT_SUPPORTED +#endif + +#ifndef CPP14_NOT_SUPPORTED +#define FASTFLOAT_CONDITIONAL_T(condition, true_t, false_t) \ + std::conditional_t +#else +template +struct conditional { + using type = false_t; +}; + +template +struct conditional { + using type = true_t; +}; + +template +using conditional_t = typename conditional::type; + +#define FASTFLOAT_CONDITIONAL_T(condition, true_t, false_t) \ + conditional_t +#endif + namespace detail { // adjust for deprecated feature macros constexpr chars_format adjust_for_feature_macros(chars_format fmt) {