File indexing completed on 2025-04-19 08:19:41
0001
0002
0003
0004
0005 #ifndef BOOST_CHARCONV_LIMITS_HPP
0006 #define BOOST_CHARCONV_LIMITS_HPP
0007
0008 #include <boost/charconv/detail/config.hpp>
0009 #include <limits>
0010 #include <type_traits>
0011
0012 namespace boost { namespace charconv {
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 namespace detail
0023 {
0024
0025 constexpr int exp_digits( int exp )
0026 {
0027 return exp < 100? 2: exp < 1000? 3: exp < 10000? 4: 5;
0028 }
0029
0030 #if defined(BOOST_HAS_INT128)
0031
0032 template<class T> struct is_int128: std::is_same<T, boost::int128_type> {};
0033 template<class T> struct is_uint128: std::is_same<T, boost::int128_type> {};
0034
0035 #else
0036
0037 template<class T> struct is_int128: std::false_type {};
0038 template<class T> struct is_uint128: std::false_type {};
0039
0040 #endif
0041
0042 }
0043
0044 template<typename T> struct limits
0045 {
0046 BOOST_ATTRIBUTE_UNUSED static constexpr int max_chars10 =
0047
0048
0049 detail::is_int128<T>::value? 38+2:
0050
0051
0052 detail::is_uint128<T>::value? 38+1:
0053
0054
0055 std::numeric_limits<T>::is_integer? std::numeric_limits<T>::digits10 + 1 + std::numeric_limits<T>::is_signed:
0056
0057
0058 std::numeric_limits<T>::max_digits10 + 3 + 2 + detail::exp_digits( std::numeric_limits<T>::max_exponent10 );
0059
0060 BOOST_ATTRIBUTE_UNUSED static constexpr int max_chars =
0061
0062
0063 detail::is_int128<T>::value? 127+2:
0064
0065
0066 detail::is_uint128<T>::value? 128+1:
0067
0068
0069 std::numeric_limits<T>::is_integer? std::numeric_limits<T>::digits + 1 + std::numeric_limits<T>::is_signed:
0070
0071
0072 std::numeric_limits<T>::max_digits10 + 3 + 2 + detail::exp_digits( std::numeric_limits<T>::max_exponent10 );
0073 };
0074
0075 #if defined(BOOST_CHARCONV_HAS_QUADMATH)
0076
0077 template <> struct limits<__float128>
0078 {
0079 BOOST_ATTRIBUTE_UNUSED static constexpr int max_chars10 = 33 + 3 + 2 + 5;
0080 BOOST_ATTRIBUTE_UNUSED static constexpr int max_chars = max_chars10;
0081 };
0082
0083 #endif
0084
0085 #if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
0086
0087
0088
0089 template<typename T> BOOST_ATTRIBUTE_UNUSED constexpr int limits<T>::max_chars10;
0090 template<typename T> BOOST_ATTRIBUTE_UNUSED constexpr int limits<T>::max_chars;
0091
0092 #endif
0093
0094 }}
0095
0096 #endif