[Development] Deprecating QString::{v,}sprintf()
Marc Mutz
marc.mutz at kdab.com
Tue Feb 21 10:56:41 CET 2012
On Tuesday February 21 2012, Thiago Macieira wrote:
> On terça-feira, 21 de fevereiro de 2012 10.33.12, Marc Mutz wrote:
> > 2. Add static QString::{v,}asprintf()
>
> Do we need them? You can't pass non-POD via ellipsis, so it's not very easy
> to use. I'd much rather you invested time in a C++-style formatting.
>
> We already have QString::arg().
qlogging.cpp would be quite a bit more complicated without it...
I also need some function to back up sprintf() so QT_NO_DEPRECATED builds
remain BiC.
On a more general line: QString::sprintf() is the only implementation of a
printf-style formatter in Qt that allocates its target string, and therefore
doesn't suffer from the problems of all other functions (except asprintf)
about buffer lengths.
Look at http://linux.die.net/man/3/vsnprintf, make_message Example, to see how
horrendous correct implementation of an arbitrary-length version of printf()
otherwise is.
Bottomline: until we can expect variadic template support for Qt, I think we
need to keep it. Many people have over the years tried to eradicate printf,
but it's syntax is just too compact.
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4700 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120221/54a05960/attachment.bin>
More information about the Development
mailing list