[Interest] Why QString and not std::string?

Jonas Gehring jonas.gehring at boolsoft.org
Fri Jun 15 19:48:26 CEST 2012


On 6/15/12 10:18 AM, Konstantin Tokarev wrote:
> 
> 
> 15.06.2012, 17:50, "Giuseppe D'Angelo" <dangelog at gmail.com>:
>> On 15 June 2012 14:35, Sven Anderson <Sven.Anderson at snom.com> wrote:
>>
>>>  On 15.06.2012 14:58, Thiago Macieira wrote:
>>>>  Any one care to give me the Standard Library equivalent of:
>>>>
>>>>        QString::number(x)
>>>  string to_string(int) ?
>>
>> No go, C++11 only.
> 
> #if NO_CXX11_AVAILABLE
> std::string to_string(int x)
> {
>     std::static_cast<std::ostringstream*>( &(std::ostringstream() << x ) )->str();
> }
> #endif
> 

It works, but it's terribly slow: sprintf is 5 times faster on my
system. Benchmark is at https://gist.github.com/2937802.

Chhers,
Jonas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120615/ea2a2d27/attachment.sig>


More information about the Interest mailing list