[Development] How to make a fancy QMap c++17 initializer_list
Henry Skoglund
fromqt at tungware.se
Mon Jul 24 21:44:12 CEST 2017
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
More information about the Development
mailing list