add support for formatting pointers

master
Daniel Kolesa 2015-07-03 21:19:50 +01:00
parent bc2bb5e635
commit 2d21a894cd
1 changed files with 11 additions and 1 deletions

View File

@ -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<typename R, typename T>
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<typename R, typename T>
octa::Ptrdiff write(R &writer, const T &val, octa::EnableIf<