Adding conditional_t for pre-CPP14.

This commit is contained in:
RealTimeChris 2024-11-27 07:41:08 -05:00
parent d88299dd4c
commit 1f032e3afd
2 changed files with 36 additions and 2 deletions

View File

@ -29,9 +29,9 @@ template <typename UC> fastfloat_really_inline constexpr bool has_simd_opt() {
}
template <typename value_type> struct get_equal_sized_uint {
using type = std::conditional_t<
using type = FASTFLOAT_CONDITIONAL_T(
sizeof(value_type) == 4, uint32_t,
std::conditional_t<sizeof(value_type) == 2, uint16_t, uint8_t>>;
FASTFLOAT_CONDITIONAL_T(sizeof(value_type) == 2, uint16_t, uint8_t));
};
template <typename value_type>

View File

@ -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<condition, true_t, false_t>
#else
template <bool condition, typename true_t, typename false_t>
struct conditional {
using type = false_t;
};
template <typename true_t, typename false_t>
struct conditional<true, true_t, false_t> {
using type = true_t;
};
template <bool condition, typename true_t, typename false_t>
using conditional_t = typename conditional<condition, true_t, false_t>::type;
#define FASTFLOAT_CONDITIONAL_T(condition, true_t, false_t) \
conditional_t<condition, true_t, false_t>
#endif
namespace detail {
// adjust for deprecated feature macros
constexpr chars_format adjust_for_feature_macros(chars_format fmt) {