Skip to content

Commit

Permalink
Adding conditional_t for pre-CPP14.
Browse files Browse the repository at this point in the history
  • Loading branch information
RealTimeChris committed Nov 27, 2024
1 parent d88299d commit 1a2b6cc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fast_float/ascii_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
34 changes: 34 additions & 0 deletions include/fast_float/float_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
typedef false_t type;
};

template <typename true_t, typename false_t>
struct conditional<true, true_t, false_t> {
typedef true_t type;
};

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) {
Expand Down

0 comments on commit 1a2b6cc

Please sign in to comment.