![]() |
Home · All Classes · alphabetical Classes List · Modules · Functions · |
Tuples and cons pairs are both pretty common template metaprogramming hacks. This set of classes attempts to implement a healthy balance between the two. Tuples generally are implemented with a fixed length; cons pairs have a lot of overhead and require a ton of typing. As with all template metaprograms, it may take a while to compile.
It is recommended to use the convenience macros to create tuples, but you can construct the QxtTypeList template yourself if you desire; this may be preferable if you want to write generic functions that use tuples.
----- example:
#include <QxtTuple.h> #include <iostream> using namespace std; int main(int argc, char** argv) { Qxt7Tuple(bool, char, short, int, long long, float, double) tuple; tuple.setValue<0>(true); tuple.setValue<1>('a'); tuple.setValue<2>(32767); tuple.setValue<3>(1234567); tuple.setValue<4>(987654321); tuple.setValue<5>(1.414); tuple.setValue<6>(3.14159265); cout << 0 << "=" << tuple.value<0>() << endl; cout << 1 << "=" << tuple.value<1>() << endl; cout << 2 << "=" << tuple.value<2>() << endl; cout << 3 << "=" << tuple.value<3>() << endl; cout << 4 << "=" << tuple.value<4>() << endl; cout << 5 << "=" << tuple.value<5>() << endl; cout << 6 << "=" << tuple.value<6>() << endl; }
Declares a one-column tuple.
Declares a two-column tuple, similar to QPair.
Declares a three-column tuple, similar to QxtTriple.
Declares a four-column tuple.
Declares a five-column tuple.
Declares a six-column tuple.
Declares a seven-column tuple.
Declares an eight-column tuple.
Declares a nine-column tuple.
Declares an extended tuple with ten or more columns. Pay special attention to the syntax of the tenth parameter, which must be a QxtTypeList, not a storage type.
QxtLongTuple(int, int, int, int, int, int, int, int, int, QxtTypeList<int>) tuple; // correct way to implement a 10-tuple QxtLongTuple(int, int, int, int, int, int, int, int, int, int) tuple; // this will produce a (very long) compile-time error
(c) 2007A.Picciani and A.Higerd LGPL | libqxt 0.2 |