Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a QPair class, but for three+ items instead of two?

Tags:

c++

struct

qt

QPair is nice, but what if I need 3 items? Should I just make a struct, or does Qt have me covered?

like image 844
Anon Avatar asked Feb 20 '16 16:02

Anon


1 Answers

As QTBUG-22441 indicates, the developers have no intention of adding a Qt analog of std::tuple. (Even though QTBUG-3283 gives us hope that it could be done, it's dated Dec'09, while the newer report, with a WONTFIX, is dated May'15). Thus, you need to fall back to std::tuple or come up with your own data structure.

Quote from Marc Mutz:

A hypothetical QTuple wouldn't do anything differently, anyway, except drain Qt developer resources.

Moreover, the docs for Qt 5 Algorithms module state the following explicitly:

Historically, Qt used to provide functions which were direct equivalents of many STL algorithmic functions. Starting with Qt 5.0, you are instead encouraged to use directly the implementations available in the STL; most of the Qt ones have been deprecated (although they are still available to keep the old code compiling).

So using STL when programming with Qt 5 is officially encouraged, should it become a necessity.

like image 103
iksemyonov Avatar answered Nov 15 '22 05:11

iksemyonov