Le 24/07/2017 à 21:44, Henry Skoglund a écrit :
On 2017-07-24 21:32, Grégoire Barbier wrote:
Le 24/07/2017 à 18:45, Henry Skoglund a écrit :
QMap m1 = {std::pair{2,"score"}, {4,"seven"}, {1,"Four"}, {5,"years"}, {3,"and"}, {6,"ago"}};

Or even this:

QMap<int, const char*> m1 { {2, "score"}, {4, "seven"}, };


Yes that works nicely too but it's not bleeding edge/c++17 :-)

This post was just to show that in c++17 it's possible to declare a QMap without any trailing <> i.e. letting the compiler figure out the types (less visual clutter) More here: http://en.cppreference.com/w/cpp/language/class_template_argument_deduction

Rgrds Henry

Sorry I missed your point, by far.

Anyway it's not easy: I played a little bit on godbolt.org and locally on my computer and it seems that gcc 7.1 only deduces templates argument with a depth of 1 (never with templates of templates), ICC 17 and MSVC 15.2 being worst on this point (not deducing at all, if I did not miss something).

Even when addind deduction guides like I tried here: https://godbolt.org/g/pC8SaV

So, I'll wait and keep my explicit template arguments if needed a few more years, and keep being thankful to all pioneers like you who use it now and will make compilers better... :-)

--
Grégoire Barbier :: g à g76r.eu
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to