Hello, I've been testing more C++17 class template auto deduction awith gcc-7, and got stuck on QMap, consider this simple test program:

-------------------------------------------------------------
#include "qapplication.h"
#include "qmap.h"
#include "qdebug.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

QMap m = {std::pair{2,"score"}, {4,"seven"}, {1,"Four"}, {5,"years"}, {3,"and"}, {6,"ago"}};

    for (auto v : m)
        qDebug() << v;
}
-------------------------------------------------------------

I really would like to just write a {{Key,T}..} list but it will not compile. As a kludge/compromise it works if I write "std::pair" around the first {} pair, to force the compiler to see it my way. Then the speech of Mr. Lincoln comes out fine.

In C++17 you should be able to fix this through a "User-defined deduction guide" to help the compiler. I've been trying various template one-liners but alas, I think my brain is too small. Anyone got a clue?

Rgrds Henry

_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to