From 2d21a894cd9fec53fa16c66fbfa16d7e9633797a Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 3 Jul 2015 21:19:50 +0100 Subject: [PATCH] add support for formatting pointers --- octa/format.hh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/octa/format.hh b/octa/format.hh index c906094..6fef74f 100644 --- a/octa/format.hh +++ b/octa/format.hh @@ -276,7 +276,7 @@ namespace detail { int pfxlen = 0; if (fl->flags & FMT_FLAG_HASH && spec != 'd') { pfx = octa::detail::fmt_intpfx[spec >= 'a'][specn - 3]; - pfxlen = strlen(pfx); + pfxlen = !!pfx[1] + 1; r += pfxlen; } @@ -400,6 +400,16 @@ namespace detail { return ret; } + /* pointer value */ + template + octa::Ptrdiff write(R &writer, T *val) { + if (this->spec == 's') { + this->spec = 'x'; + this->flags |= FMT_FLAG_HASH; + } + return write(writer, octa::Size(val)); + } + /* generic value */ template octa::Ptrdiff write(R &writer, const T &val, octa::EnableIf<