| 1 | // Copyright 2022 Peter Dimov |
| 2 | // Copyright 2023 Matt Borland |
| 3 | // Copyright 2023 Junekey Jeon |
| 4 | // Distributed under the Boost Software License, Version 1.0. |
| 5 | // https://www.boost.org/LICENSE_1_0.txt |
| 6 | |
| 7 | #ifndef BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED |
| 8 | #define BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED |
| 9 | |
| 10 | #include <boost/charconv/detail/to_chars_integer_impl.hpp> |
| 11 | #include <boost/charconv/detail/to_chars_result.hpp> |
| 12 | #include <boost/charconv/config.hpp> |
| 13 | #include <boost/charconv/chars_format.hpp> |
| 14 | |
| 15 | namespace boost { |
| 16 | namespace charconv { |
| 17 | |
| 18 | // integer overloads |
| 19 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, bool value, int base) noexcept = delete; |
| 20 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, char value, int base = 10) noexcept |
| 21 | { |
| 22 | return detail::to_chars_int(first, last, value, base); |
| 23 | } |
| 24 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, signed char value, int base = 10) noexcept |
| 25 | { |
| 26 | return detail::to_chars_int(first, last, value, base); |
| 27 | } |
| 28 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned char value, int base = 10) noexcept |
| 29 | { |
| 30 | return detail::to_chars_int(first, last, value, base); |
| 31 | } |
| 32 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, short value, int base = 10) noexcept |
| 33 | { |
| 34 | return detail::to_chars_int(first, last, value, base); |
| 35 | } |
| 36 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned short value, int base = 10) noexcept |
| 37 | { |
| 38 | return detail::to_chars_int(first, last, value, base); |
| 39 | } |
| 40 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, int value, int base = 10) noexcept |
| 41 | { |
| 42 | return detail::to_chars_int(first, last, value, base); |
| 43 | } |
| 44 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned int value, int base = 10) noexcept |
| 45 | { |
| 46 | return detail::to_chars_int(first, last, value, base); |
| 47 | } |
| 48 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long value, int base = 10) noexcept |
| 49 | { |
| 50 | return detail::to_chars_int(first, last, value, base); |
| 51 | } |
| 52 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long value, int base = 10) noexcept |
| 53 | { |
| 54 | return detail::to_chars_int(first, last, value, base); |
| 55 | } |
| 56 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, long long value, int base = 10) noexcept |
| 57 | { |
| 58 | return detail::to_chars_int(first, last, value, base); |
| 59 | } |
| 60 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, unsigned long long value, int base = 10) noexcept |
| 61 | { |
| 62 | return detail::to_chars_int(first, last, value, base); |
| 63 | } |
| 64 | |
| 65 | #ifdef BOOST_CHARCONV_HAS_INT128 |
| 66 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::int128_type value, int base = 10) noexcept |
| 67 | { |
| 68 | return detail::to_chars128(first, last, value, base); |
| 69 | } |
| 70 | BOOST_CHARCONV_CONSTEXPR to_chars_result to_chars(char* first, char* last, boost::uint128_type value, int base = 10) noexcept |
| 71 | { |
| 72 | return detail::to_chars128(first, last, value, base); |
| 73 | } |
| 74 | #endif |
| 75 | |
| 76 | //---------------------------------------------------------------------------------------------------------------------- |
| 77 | // Floating Point |
| 78 | //---------------------------------------------------------------------------------------------------------------------- |
| 79 | |
| 80 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, |
| 81 | chars_format fmt = chars_format::general) noexcept; |
| 82 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, |
| 83 | chars_format fmt = chars_format::general) noexcept; |
| 84 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, |
| 85 | chars_format fmt = chars_format::general) noexcept; |
| 86 | |
| 87 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, float value, |
| 88 | chars_format fmt, int precision) noexcept; |
| 89 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double value, |
| 90 | chars_format fmt, int precision) noexcept; |
| 91 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value, |
| 92 | chars_format fmt, int precision) noexcept; |
| 93 | |
| 94 | #ifdef BOOST_CHARCONV_HAS_FLOAT128 |
| 95 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, |
| 96 | chars_format fmt = chars_format::general) noexcept; |
| 97 | |
| 98 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value, |
| 99 | chars_format fmt, int precision) noexcept; |
| 100 | #endif |
| 101 | |
| 102 | #ifdef BOOST_CHARCONV_HAS_FLOAT16 |
| 103 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, |
| 104 | chars_format fmt = chars_format::general) noexcept; |
| 105 | |
| 106 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float16_t value, |
| 107 | chars_format fmt, int precision) noexcept; |
| 108 | #endif |
| 109 | #ifdef BOOST_CHARCONV_HAS_FLOAT32 |
| 110 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, |
| 111 | chars_format fmt = chars_format::general) noexcept; |
| 112 | |
| 113 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float32_t value, |
| 114 | chars_format fmt, int precision) noexcept; |
| 115 | #endif |
| 116 | #ifdef BOOST_CHARCONV_HAS_FLOAT64 |
| 117 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, |
| 118 | chars_format fmt = chars_format::general) noexcept; |
| 119 | |
| 120 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float64_t value, |
| 121 | chars_format fmt, int precision) noexcept; |
| 122 | #endif |
| 123 | #if defined(BOOST_CHARCONV_HAS_STDFLOAT128) && defined(BOOST_CHARCONV_HAS_FLOAT128) |
| 124 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, |
| 125 | chars_format fmt = chars_format::general) noexcept; |
| 126 | |
| 127 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::float128_t value, |
| 128 | chars_format fmt, int precision) noexcept; |
| 129 | #endif |
| 130 | #ifdef BOOST_CHARCONV_HAS_BRAINFLOAT16 |
| 131 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, |
| 132 | chars_format fmt = chars_format::general) noexcept; |
| 133 | |
| 134 | BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, std::bfloat16_t value, |
| 135 | chars_format fmt, int precision) noexcept; |
| 136 | #endif |
| 137 | |
| 138 | } // namespace charconv |
| 139 | } // namespace boost |
| 140 | |
| 141 | #endif // #ifndef BOOST_CHARCONV_TO_CHARS_HPP_INCLUDED |
| 142 | |