• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

Classes
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< TList, T >
 
class  KTypeListLength< TList >
 
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:

  • an empty list is of type KDE::NullType (the terminal marker)
  • a one-element list with element T is of type KTypeList<T, KDE::NullType>.
  • a two-element list with elements T and U is of type KTypeList<T, KTypeList<U, KDE::NullType> >.
  • an N-Element list with the first element T and the remaining elements Rest is of type KTypeList<T, Rest>.

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:

  • KTypeListLength: determine the number of elements in a typelist
  • KTypeListIndexOf: find a given type in a typelist

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 Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal