[Development] A taste of the future: declaring QLists without <>

Henry Skoglund fromqt at tungware.se
Thu Jul 13 03:08:14 CEST 2017


Hi,

reading about the new C++17 standard, I decided to test some Qt code:
...
QList<int> li = {7,8,4,2,5,4,3};
QList ll = {5,3,34,5,44};

qDebug() << li;
qDebug() << ll;
...

The normal g++ 5.4 on vanilla Qt 5.9.1 on my Ubuntu 16.04 returns:
"home/henry/test/mainwindow.cpp:13: error: missing template arguments 
before ‘ll’
      QList ll = {5,3,34,5,44};
            ^
Upgraded gcc to g++ 6. Same error. But finding this ppa: 
https://launchpad.net/~jonathonf/+archive/ubuntu/gcc-7.1
I've managed to upgrade to the spanking new g++ 7.1, and voila, no sour 
grapes from the compiler (i.e the 2 qDebug() statements above returned 
both their proper lists). Nice!

Rgrds Henry





More information about the Development mailing list