7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_FORMAT_TO_INLINE_STRING_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_FORMAT_TO_INLINE_STRING_HPP_
14#include "arene/base/array/array.hpp"
15#include "arene/base/constraints/constraints.hpp"
16#include "arene/base/contracts/contract.hpp"
17#include "arene/base/detail/raw_c_string.hpp"
18#include "arene/base/math/power_of_2.hpp"
19#include "arene/base/stdlib_choice/climits.hpp"
20#include "arene/base/stdlib_choice/cstddef.hpp"
21#include "arene/base/stdlib_choice/cstdint.hpp"
22#include "arene/base/stdlib_choice/enable_if.hpp"
23#include "arene/base/stdlib_choice/ignore.hpp"
24#include "arene/base/stdlib_choice/integral_constant.hpp"
25#include "arene/base/stdlib_choice/is_integral.hpp"
26#include "arene/base/stdlib_choice/is_signed.hpp"
27#include "arene/base/stdlib_choice/is_unsigned.hpp"
28#include "arene/base/stdlib_choice/make_unsigned.hpp"
29#include "arene/base/stdlib_choice/numeric_limits.hpp"
30#include "arene/base/strings/inline_string.hpp"
38namespace to_string_detail {
44inline constexpr auto digits_for_integral_value() -> std::size_t {
45 constexpr std::size_t twenty_five{25U};
46 constexpr std::size_t two_to_the_25th{::arene::base::power_of_2(twenty_five)};
48 constexpr std::size_t log2_of_10_scaled_by_2_to_25{111465410U};
49 constexpr std::size_t signed_digit_size{std::is_signed<T>::value ? 1U : 0U};
50 return ((
sizeof(T) *
static_cast<std::size_t>(CHAR_BIT) - signed_digit_size) * two_to_the_25th +
51 log2_of_10_scaled_by_2_to_25 - 1U) /
52 log2_of_10_scaled_by_2_to_25 +
58template <
typename T,
typename = constraints<>>
59class required_decimal_digits;
65class required_decimal_digits<T, constraints<std::enable_if_t<std::is_integral<T>::value>>>
66 :
public std::integral_constant<std::size_t, digits_for_integral_value<T>()> {};
71class required_decimal_digits<
bool> :
public std::integral_constant<std::size_t, 5> {};
76extern constexpr auto required_decimal_digits_v = required_decimal_digits<T>::value;
82template <
typename T, std::size_t S>
83extern constexpr bool is_large_enough_for{S >= required_decimal_digits_v<T>};
88template <
typename T, constraints<std::enable_if_t<std::is_unsigned<T>::value>> =
nullptr>
89constexpr auto is_negative_value(T)
noexcept ->
bool {
97template <
typename T, constraints<std::enable_if_t<std::is_signed<T>::value>> =
nullptr>
98constexpr auto is_negative_value(T value)
noexcept ->
bool {
106inline constexpr auto digit(std::uintmax_t
const value)
noexcept -> arene::base::detail::character {
108 constexpr array<arene::base::detail::character, 10> digits{{
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'}};
110 ARENE_PRECONDITION(value < std::uintmax_t{digits.size()});
111 return digits[
static_cast<std::size_t>(value)];
118extern constexpr T zero_v{0};
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10