template write_u (use the most efficient unsigned storage)

master
Daniel Kolesa 2015-07-03 01:59:34 +01:00
parent c6db1a8b47
commit 7e3a755f9a
1 changed files with 4 additions and 3 deletions

View File

@ -246,9 +246,9 @@ namespace detail {
/* Integer helpers */
template<typename R>
template<typename R, typename T>
static inline octa::Size write_u(R &writer, const FormatSpec &fl,
bool neg, octa::Uintmax val) {
bool neg, T val) {
char buf[20];
octa::Size n = 0;
for (; val; val /= 10) buf[n++] = '0' + val % 10;
@ -276,8 +276,9 @@ namespace detail {
template<typename R, typename T> struct WriteIntVal<R, T, true, true> {
static inline octa::Size write(R &writer, const FormatSpec &fl, T val) {
using UT = octa::MakeUnsigned<T>;
return octa::detail::write_u(writer, fl, val < 0,
(val < 0) ? -val : val);
(val < 0) ? UT(-val) : UT(val));
}
};