KDELibs4Support

Typelist classes, algorithms and macros

Classes

struct  KMakeTypeList< T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18 >
 
struct  KTypeList< T, U >
 
class  KTypeListIndexOf
 
class  KTypeListLength
 
class  NullType
 

Detailed Description

Typelists are lists of C++ types of arbitrary length. They are used to carry type information at compile-time.

Internally, typelists are represented by the KTypeList template class. The KTypeList class uses the recursive structure of singly-linked lists which is common in functional programming languages:

Note that the last element of a typelist is always KDE::NullType. Also note that this is only a convention, it is not enforced by anything. But if these rules are broken, the compile-time algorithms defined for typelists don't work.

To ease the definition of typelists, there are some macros which expand to nested KTypeList definitions. These macros have the form

K_TYPELIST_N(T1, T2, ..., TN)

where N is the number of types in the list (e.g. K_TYPELIST_3())

In addition to that, and also as the preferred way, there is the KMakeTypeList template which takes an arbitrary number of type arguments (up to 18) and exports a nested typedef called Result which equals a KTypeList with the list of provided arguments.

To work with typelists, several compile-time algorithms are provided:

For a detailed discussion about typelists, see the book "Modern C++ Design: Generic Programming and Design Patterns Applied" by Andrei Alexandrescu, and/or the Loki Library at http://sourceforge.net/projects/loki-lib/

This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 03:59:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.