C++ (Qt)const ushort *QString::utf16() const{ if (IS_RAW_DATA(d)) { // ensure '\0'-termination for ::fromRawData strings const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); } return d->data();}
C++ (Qt)struct type { int i; type(): i(3) {} void f(int v) const { // this->i = v; // compile error: this is a pointer to const const_cast<type*>(this)->i = v; // OK as long as the type object isn't const }}; type t; // if this was const type t, then t.f(4) would be undefined behaviort.f(4);
C++ (Qt)const QString str = QString::fromRawData(unicode, size);
C++ (Qt)static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };QString str = QString::fromRawData(data, 4);const QChar * p0 = str.constData();const ushort * utf = str.utf16();const QChar * p1 = str.constData();qDebug() << data << p0 << p1 << (p0 == p1);