Writes a value without checking the buffer length with regards to the required number of digits to encode the value.
More...
Writes a value without checking the buffer length with regards to the required number of digits to encode the value.
It is the responsibility of the caller to ensure that the provided number of digits is enough to write the given value. Notwithstanding the name, assertions are liberally performed, so this code is safe.
◆ write_dec_unchecked()
template<class T >
| void c4::write_dec_unchecked |
( |
substr |
buf, |
|
|
T |
v, |
|
|
unsigned |
digits_v |
|
) |
| |
|
inlinenoexcept |
Definition at line 601 of file charconv.hpp.
603 C4_STATIC_ASSERT(std::is_integral<T>::value);
605 C4_ASSERT(buf.len >= digits_v);
612 const auto num = (v - quo * T(100)) << 1u;
614 buf.str[--digits_v] = detail::digits0099[num + 1];
615 buf.str[--digits_v] = detail::digits0099[num];
619 C4_ASSERT(digits_v == 2);
620 const auto num = v << 1u;
621 buf.str[1] = detail::digits0099[num + 1];
622 buf.str[0] = detail::digits0099[num];
626 C4_ASSERT(digits_v == 1);
627 buf.str[0] = (char)(
'0' + v);
auto digits_dec(T v) noexcept -> typename std::enable_if< sizeof(T)==1u, unsigned >::type
decimal digits for 8 bit integers
References c4::digits_dec().
◆ write_hex_unchecked()
template<class T >
| void c4::write_hex_unchecked |
( |
substr |
buf, |
|
|
T |
v, |
|
|
unsigned |
digits_v |
|
) |
| |
|
inlinenoexcept |
Definition at line 634 of file charconv.hpp.
636 C4_STATIC_ASSERT(std::is_integral<T>::value);
638 C4_ASSERT(buf.len >= digits_v);
641 buf.str[--digits_v] = detail::hexchars[v & T(15)];
644 C4_ASSERT(digits_v == 0);
unsigned digits_hex(T v) noexcept
return the number of digits required to encode an hexadecimal number.
References c4::digits_hex().
◆ write_oct_unchecked()
template<class T >
| void c4::write_oct_unchecked |
( |
substr |
buf, |
|
|
T |
v, |
|
|
unsigned |
digits_v |
|
) |
| |
|
inlinenoexcept |
Definition at line 650 of file charconv.hpp.
652 C4_STATIC_ASSERT(std::is_integral<T>::value);
654 C4_ASSERT(buf.len >= digits_v);
657 buf.str[--digits_v] = (char)(
'0' + (v & T(7)));
660 C4_ASSERT(digits_v == 0);
unsigned digits_oct(T v_) noexcept
return the number of digits required to encode an octal number.
References c4::digits_oct().
◆ write_bin_unchecked()
template<class T >
| void c4::write_bin_unchecked |
( |
substr |
buf, |
|
|
T |
v, |
|
|
unsigned |
digits_v |
|
) |
| |
|
inlinenoexcept |
Definition at line 666 of file charconv.hpp.
668 C4_STATIC_ASSERT(std::is_integral<T>::value);
670 C4_ASSERT(buf.len >= digits_v);
673 buf.str[--digits_v] = (char)(
'0' + (v & T(1)));
676 C4_ASSERT(digits_v == 0);
unsigned digits_bin(T v) noexcept
return the number of digits required to encode a binary number.
References c4::digits_bin().