1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #ifndef BOOST_JSON_DETAIL_CHARCONV_LIMITS_HPP
- #define BOOST_JSON_DETAIL_CHARCONV_LIMITS_HPP
- #include <boost/config.hpp>
- #include <limits>
- #include <type_traits>
- namespace boost { namespace json { namespace detail { namespace charconv {
- namespace detail
- {
- constexpr int exp_digits( int exp )
- {
- return exp < 100? 2: exp < 1000? 3: exp < 10000? 4: 5;
- }
- #if defined(BOOST_HAS_INT128)
- template<class T> struct is_int128: std::is_same<T, boost::int128_type> {};
- template<class T> struct is_uint128: std::is_same<T, boost::int128_type> {};
- #else
- template<class T> struct is_int128: std::false_type {};
- template<class T> struct is_uint128: std::false_type {};
- #endif
- }
- template<typename T> struct limits
- {
- static constexpr int max_chars10 =
-
- detail::is_int128<T>::value? 38+2:
-
- detail::is_uint128<T>::value? 38+1:
-
- std::numeric_limits<T>::is_integer? std::numeric_limits<T>::digits10 + 1 + std::numeric_limits<T>::is_signed:
-
- std::numeric_limits<T>::max_digits10 + 3 + 2 + detail::exp_digits( std::numeric_limits<T>::max_exponent10 );
- static constexpr int max_chars =
-
- detail::is_int128<T>::value? 127+2:
-
- detail::is_uint128<T>::value? 128+1:
-
- std::numeric_limits<T>::is_integer? std::numeric_limits<T>::digits + 1 + std::numeric_limits<T>::is_signed:
-
- std::numeric_limits<T>::max_digits10 + 3 + 2 + detail::exp_digits( std::numeric_limits<T>::max_exponent10 );
- };
- #if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
- template<typename T> constexpr int limits<T>::max_chars10;
- template<typename T> constexpr int limits<T>::max_chars;
- #endif
- }}}}
- #endif
|