Skip to content

Commit 1f032e3

Browse files
committed
Adding conditional_t for pre-CPP14.
1 parent d88299d commit 1f032e3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

include/fast_float/ascii_number.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ template <typename UC> fastfloat_really_inline constexpr bool has_simd_opt() {
2929
}
3030

3131
template <typename value_type> struct get_equal_sized_uint {
32-
using type = std::conditional_t<
32+
using type = FASTFLOAT_CONDITIONAL_T(
3333
sizeof(value_type) == 4, uint32_t,
34-
std::conditional_t<sizeof(value_type) == 2, uint16_t, uint8_t>>;
34+
FASTFLOAT_CONDITIONAL_T(sizeof(value_type) == 2, uint16_t, uint8_t));
3535
};
3636

3737
template <typename value_type>

include/fast_float/float_common.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,40 @@ operator^=(chars_format &lhs, chars_format rhs) noexcept {
883883
return lhs = (lhs ^ rhs);
884884
}
885885

886+
#if defined(_MSC_VER)
887+
#if _MSC_VER >= 1900
888+
#if _MSC_VER >= 1910
889+
#else
890+
#define CPP14_NOT_SUPPORTED
891+
#endif
892+
#else
893+
#define CPP14_NOT_SUPPORTED
894+
#endif
895+
#elif __cplusplus < 201402L
896+
#define CPP14_NOT_SUPPORTED
897+
#endif
898+
899+
#ifndef CPP14_NOT_SUPPORTED
900+
#define FASTFLOAT_CONDITIONAL_T(condition, true_t, false_t) \
901+
std::conditional_t<condition, true_t, false_t>
902+
#else
903+
template <bool condition, typename true_t, typename false_t>
904+
struct conditional {
905+
using type = false_t;
906+
};
907+
908+
template <typename true_t, typename false_t>
909+
struct conditional<true, true_t, false_t> {
910+
using type = true_t;
911+
};
912+
913+
template <bool condition, typename true_t, typename false_t>
914+
using conditional_t = typename conditional<condition, true_t, false_t>::type;
915+
916+
#define FASTFLOAT_CONDITIONAL_T(condition, true_t, false_t) \
917+
conditional_t<condition, true_t, false_t>
918+
#endif
919+
886920
namespace detail {
887921
// adjust for deprecated feature macros
888922
constexpr chars_format adjust_for_feature_macros(chars_format fmt) {

0 commit comments

Comments
 (0)