File indexing completed on 2025-04-19 08:19:39
0001
0002
0003
0004
0005 #ifndef BOOST_CHARCONV_DETAIL_CONFIG_HPP
0006 #define BOOST_CHARCONV_DETAIL_CONFIG_HPP
0007
0008 #include <boost/config.hpp>
0009 #include <type_traits>
0010 #include <cfloat>
0011
0012 #include <boost/assert.hpp>
0013 #define BOOST_CHARCONV_ASSERT(expr) BOOST_ASSERT(expr)
0014 #define BOOST_CHARCONV_ASSERT_MSG(expr, msg) BOOST_ASSERT_MSG(expr, msg)
0015
0016 #ifdef BOOST_CHARCONV_DEBUG
0017 # define BOOST_CHARCONV_DEBUG_ASSERT(expr) BOOST_CHARCONV_ASSERT(expr)
0018 #else
0019 # define BOOST_CHARCONV_DEBUG_ASSERT(expr)
0020 #endif
0021
0022
0023 #if defined(BOOST_HAS_INT128)
0024 # define BOOST_CHARCONV_HAS_INT128
0025 # define BOOST_CHARCONV_INT128_MAX static_cast<boost::int128_type>((static_cast<boost::uint128_type>(1) << 127) - 1)
0026 # define BOOST_CHARCONV_INT128_MIN (-BOOST_CHARCONV_INT128_MAX - 1)
0027 # define BOOST_CHARCONV_UINT128_MAX (2 * static_cast<boost::uint128_type>(BOOST_CHARCONV_INT128_MAX) + 1)
0028 #endif
0029
0030 #ifndef BOOST_NO_CXX14_CONSTEXPR
0031 # define BOOST_CHARCONV_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
0032 # define BOOST_CHARCONV_CXX14_CONSTEXPR_NO_INLINE BOOST_CXX14_CONSTEXPR
0033 #else
0034 # define BOOST_CHARCONV_CXX14_CONSTEXPR inline
0035 # define BOOST_CHARCONV_CXX14_CONSTEXPR_NO_INLINE
0036 #endif
0037
0038 #if defined(__GNUC__) && __GNUC__ == 5
0039 # define BOOST_CHARCONV_GCC5_CONSTEXPR inline
0040 #else
0041 # define BOOST_CHARCONV_GCC5_CONSTEXPR BOOST_CHARCONV_CXX14_CONSTEXPR
0042 #endif
0043
0044
0045 #if defined(__cpp_constexpr) && __cpp_constexpr >= 201603L
0046 # define BOOST_CHARCONV_CXX17_CONSTEXPR constexpr
0047 #else
0048 # define BOOST_CHARCONV_CXX17_CONSTEXPR inline
0049 #endif
0050
0051
0052 #if defined(_WIN32)
0053
0054 #define BOOST_CHARCONV_ENDIAN_BIG_BYTE 0
0055 #define BOOST_CHARCONV_ENDIAN_LITTLE_BYTE 1
0056
0057 #elif defined(__BYTE_ORDER__)
0058
0059 #define BOOST_CHARCONV_ENDIAN_BIG_BYTE (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
0060 #define BOOST_CHARCONV_ENDIAN_LITTLE_BYTE (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
0061
0062 #else
0063
0064 #error Could not determine endian type. Please file an issue at https:
0065
0066 #endif
0067
0068
0069 #if defined(BOOST_MSVC)
0070 # include <intrin.h>
0071 # if defined(_WIN64)
0072 # define BOOST_CHARCONV_HAS_MSVC_64BIT_INTRINSICS
0073 # else
0074 # define BOOST_CHARCONV_HAS_MSVC_32BIT_INTRINSICS
0075 # endif
0076 #endif
0077
0078 static_assert((BOOST_CHARCONV_ENDIAN_BIG_BYTE || BOOST_CHARCONV_ENDIAN_LITTLE_BYTE) &&
0079 !(BOOST_CHARCONV_ENDIAN_BIG_BYTE && BOOST_CHARCONV_ENDIAN_LITTLE_BYTE),
0080 "Inconsistent endianness detected. Please file an issue at https://github.com/cppalliance/charconv with your architecture");
0081
0082
0083
0084
0085 #if defined(__GNUC__) || defined(__clang__)
0086 #define BOOST_CHARCONV_SAFEBUFFERS
0087 #elif defined(_MSC_VER)
0088 #define BOOST_CHARCONV_SAFEBUFFERS __declspec(safebuffers)
0089 #else
0090 #define BOOST_CHARCONV_SAFEBUFFERS
0091 #endif
0092
0093 #if defined(__has_builtin)
0094 #define BOOST_CHARCONV_HAS_BUILTIN(x) __has_builtin(x)
0095 #else
0096 #define BOOST_CHARCONV_HAS_BUILTIN(x) false
0097 #endif
0098
0099
0100 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1933 || BOOST_MSVC == 1934)
0101 # define BOOST_CHARCONV_IF_CONSTEXPR if
0102 #else
0103 # define BOOST_CHARCONV_IF_CONSTEXPR BOOST_IF_CONSTEXPR
0104 #endif
0105
0106
0107 #ifndef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
0108 # if (defined(__clang__) && __clang_major__ < 4) || (defined(_MSC_VER) && _MSC_VER == 1900)
0109 # define BOOST_CHARCONV_NO_CXX14_RETURN_TYPE_DEDUCTION
0110 # endif
0111 #elif defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION)
0112 # define BOOST_CHARCONV_NO_CXX14_RETURN_TYPE_DEDUCTION
0113 #endif
0114
0115
0116 #ifdef __cpp_lib_is_constant_evaluated
0117 # define BOOST_CHARCONV_HAS_IS_CONSTANT_EVALUATED
0118 #endif
0119
0120 #ifdef __has_builtin
0121 # if __has_builtin(__builtin_is_constant_evaluated) && !defined(BOOST_NO_CXX14_CONSTEXPR)
0122 # define BOOST_CHARCONV_HAS_BUILTIN_IS_CONSTANT_EVALUATED
0123 # endif
0124 #endif
0125
0126
0127
0128
0129 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 192528326)
0130 # define BOOST_CHARCONV_HAS_BUILTIN_IS_CONSTANT_EVALUATED
0131 #endif
0132
0133
0134
0135
0136 #if !defined(BOOST_NO_CXX14_CONSTEXPR) && defined(__GNUC__) && (__GNUC__ >= 9) && !defined(BOOST_CHARCONV_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
0137 # define BOOST_CHARCONV_HAS_BUILTIN_IS_CONSTANT_EVALUATED
0138 #endif
0139
0140 #if defined(BOOST_CHARCONV_HAS_IS_CONSTANT_EVALUATED) && !defined(BOOST_NO_CXX14_CONSTEXPR)
0141 # define BOOST_CHARCONV_IS_CONSTANT_EVALUATED(x) std::is_constant_evaluated()
0142 #elif defined(BOOST_CHARCONV_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
0143 # define BOOST_CHARCONV_IS_CONSTANT_EVALUATED(x) __builtin_is_constant_evaluated()
0144 #elif !defined(BOOST_NO_CXX14_CONSTEXPR) && defined(__GNUC__) && (__GNUC__ >= 6)
0145 # define BOOST_CHARCONV_IS_CONSTANT_EVALUATED(x) __builtin_constant_p(x)
0146 # define BOOST_CHARCONV_USING_BUILTIN_CONSTANT_P
0147 #else
0148 # define BOOST_CHARCONV_IS_CONSTANT_EVALUATED(x) false
0149 # define BOOST_CHARCONV_NO_CONSTEXPR_DETECTION
0150 #endif
0151
0152 #ifdef BOOST_MSVC
0153 # define BOOST_CHARCONV_ASSUME(expr) __assume(expr)
0154 #elif defined(__clang__)
0155 # define BOOST_CHARCONV_ASSUME(expr) __builtin_assume(expr)
0156 #elif defined(__GNUC__)
0157 # define BOOST_CHARCONV_ASSUME(expr) if (expr) {} else { __builtin_unreachable(); }
0158 #elif defined(__has_cpp_attribute)
0159 # if __has_cpp_attribute(assume)
0160 # define BOOST_CHARCONV_ASSUME(expr) [[assume(expr)]]
0161 # else
0162 # define BOOST_CHARCONV_ASSUME(expr)
0163 # endif
0164 #else
0165 # define BOOST_CHARCONV_ASSUME(expr)
0166 #endif
0167
0168
0169
0170 #if (defined(_MSVC_LANG) && _MSVC_LANG > 202002L) || __cplusplus > 202002L
0171 # if __has_include(<stdfloat>)
0172 # include <stdfloat>
0173 # endif
0174 #endif
0175 #ifdef __STDCPP_FLOAT16_T__
0176 # define BOOST_CHARCONV_HAS_FLOAT16
0177 #endif
0178 #ifdef __STDCPP_FLOAT32_T__
0179 # define BOOST_CHARCONV_HAS_FLOAT32
0180 #endif
0181 #ifdef __STDCPP_FLOAT64_T__
0182 # define BOOST_CHARCONV_HAS_FLOAT64
0183 #endif
0184 #ifdef __STDCPP_FLOAT128_T__
0185 # define BOOST_CHARCONV_HAS_STDFLOAT128
0186 #endif
0187 #ifdef __STDCPP_BFLOAT16_T__
0188 # define BOOST_CHARCONV_HAS_BRAINFLOAT16
0189 #endif
0190
0191 #endif