mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Adding conditional_t for pre-CPP14.
This commit is contained in:
parent
d88299dd4c
commit
1f032e3afd
@ -29,9 +29,9 @@ template <typename UC> fastfloat_really_inline constexpr bool has_simd_opt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename value_type> struct get_equal_sized_uint {
|
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,
|
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>
|
template <typename value_type>
|
||||||
|
|||||||
@ -883,6 +883,40 @@ operator^=(chars_format &lhs, chars_format rhs) noexcept {
|
|||||||
return lhs = (lhs ^ rhs);
|
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 {
|
namespace detail {
|
||||||
// adjust for deprecated feature macros
|
// adjust for deprecated feature macros
|
||||||
constexpr chars_format adjust_for_feature_macros(chars_format fmt) {
|
constexpr chars_format adjust_for_feature_macros(chars_format fmt) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user