Home · All Classes · alphabetical Classes List · Modules · Functions ·

QxtTuple< TYPELIST > Class Template Reference
[Core]

Arbitrary-length templated list. More...

Related Functions

(Note that these are not member functions.)

Detailed Description

template<typename TYPELIST>
class QxtTuple< TYPELIST >

Arbitrary-length templated list.

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;
}


Friends And Related Function Documentation

template<typename TYPELIST>
Qxt1Tuple ( ) [related]

Declares a one-column tuple.


template<typename TYPELIST>
Qxt2Tuple ( a, ) [related]

Declares a two-column tuple, similar to QPair.


template<typename TYPELIST>
Qxt3Tuple ( a, b, ) [related]

Declares a three-column tuple, similar to QxtTriple.


template<typename TYPELIST>
Qxt4Tuple ( a, b, c, ) [related]

Declares a four-column tuple.


template<typename TYPELIST>
Qxt5Tuple ( a, b, c, d, ) [related]

Declares a five-column tuple.


template<typename TYPELIST>
Qxt6Tuple ( a, b, c, d, e, ) [related]

Declares a six-column tuple.


template<typename TYPELIST>
Qxt7Tuple ( a, b, c, d, e, f, ) [related]

Declares a seven-column tuple.


template<typename TYPELIST>
Qxt8Tuple ( a, b, c, d, e, f, g, ) [related]

Declares an eight-column tuple.


template<typename TYPELIST>
Qxt9Tuple ( a, b, c, d, e, f, g, h, ) [related]

Declares a nine-column tuple.


template<typename TYPELIST>
QxtLongTuple ( a, b, c, d, e, f, g, h, i, extend  ) [related]

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