3#ifndef TETL_STRINGS_CONVERSION_HPP
4#define TETL_STRINGS_CONVERSION_HPP
29template <
integral Int, from_integer_options Options = from_integer_options{}>
35 if (length < (1 +
static_cast<size_t>(Options.terminate_with_null))) {
39 if constexpr (Options.terminate_with_null) {
45 bool isNegative =
false;
47 if (num < 0 and base == 10) {
54 auto const [quot, rem] =
etl::idiv(num,
static_cast<Int
>(base));
55 auto const digit =
static_cast<char>(
etl::abs(rem));
57 str[i++] = (digit > 9) ? (digit - 10) +
'a' : digit +
'0';
65 etl::reverse(str +
static_cast<size_t>(isNegative), str + i);
66 if constexpr (Options.terminate_with_null) {
The concept integral<T> is satisfied if and only if T is an integral type.
Definition integral.hpp:13
constexpr auto reverse(BidirIt first, BidirIt last) -> void
Reverses the order of the elements in the range [first, last).
Definition reverse.hpp:16
constexpr auto abs(complex< T > const &z) -> T
Definition abs.hpp:13
from_integer_error
Definition from_integer.hpp:19
@ overflow
Definition from_integer.hpp:21
@ none
Definition from_integer.hpp:20
constexpr auto from_integer(Int num, char *str, size_t length, int base) -> from_integer_result
Definition from_integer.hpp:30
@ overflow
Definition from_floating_point.hpp:20
@ none
Definition from_floating_point.hpp:19
constexpr bool is_signed_v
Definition is_signed.hpp:30
constexpr auto idiv(Int x, Int y) noexcept -> idiv_result< Int >
Definition idiv.hpp:17
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition size_t.hpp:14
Definition from_integer.hpp:15
bool terminate_with_null
Definition from_integer.hpp:16
Definition from_integer.hpp:24
char * end
Definition from_integer.hpp:25
from_integer_error error
Definition from_integer.hpp:26