[Development] HEADS-UP: QStringLiteral

Bogdan Vatra bogdan.vatra at kdab.com
Wed Aug 21 11:50:00 CEST 2019


Hi,

În ziua de miercuri, 21 august 2019, la 00:12:59 EEST, Thiago Macieira a 
scris:
> On Tuesday, 20 August 2019 08:56:06 PDT Bogdan Vatra via Development wrote:
> >   Isn't silly to have so many wrappers around a such a simple thing as
> > 
> > strings?
> 
> We all wish it were simple. If it were, we would have no need for so many
> string classes, for Marc's email and even for SG16 (Unicode) to exist in the
> C++ committee.

You didn't answered my questions :).
  The most important one is: can we have  *A single* String class and *A* 
single sting wrapper for each UTF-X variant?

  Personally I'm not going to waste my time learning 10 sting wrappers and 
classes just to make some pico optimizations like:

QString ext = QLatin1String("exe"); // it's terribly wrong and people which 
are doing this mistake must be stoned to death!

QString ext = QStringLiteral("exe"); // it's so good and it will save the 
planet from extinction!

// But
QString ext1 = QLatin1String("exe") + ext; // it's ok
// and 
QString ext = QStringLiteral("exe") + ext; // it's a abomination!

// Even more
QHash<QString, QString> test;
test[QLatin1String("key1")] = QLatin1String("some text %1").arg(1); // wrong
test[QStringLiteral("key1")] = QStringLiteral("some text %1").arg(1); // wrong 
again
test[QLatin1String("key1")] = QStringLiteral("some text %1").arg(1); // still 
wrong
test[QLatin1String("key1")] = QStringLiteral("some text %1").arg(1); // 
victory !!!

Am I the only one which finds situations silly ? Of course there are more 
examples with the other String wrappers/functions in Qt, but I think is enough 
to show how crazy is the situation.

Cheers,
BogDan.





More information about the Development mailing list