Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
typelist.hpp File Reference

A template metaprogramming technique for manipulating collections of types. More...

Go to the source code of this file.

Description

A template metaprogramming technique for manipulating collections of types.

  • Type Sequences are used to transport a variadic sequence of types
  • Type Lists (»Loki style«) can be created from a type sequence and represent the same information by nodes with head and tail. The latter brings LISP style recursive manipulation techniques into the realm of type metaprogramming; this approach was pioneered with the Loki Library by Alexandrescu (2001) and makes complex processing much easier to write and to follow for the reader. Effectively the set of definitions used here is a tailored version of what could be found in the Loki library, and was in the following years integrated with processing of variadics, function manipulation and std::tuple. This framework is typically used to generate repetitive code, based on a collection of types, with type-specific adaptations.
    Remarks
    If you tend to find the use of template metaprogramming detrimental (or functional programming and generally any kind of abstraction) please kindly ignore the technical details and just consider the benefit of simplification for the client code.
    Interface for using this facility is the template Types<TS...> (the type sequence). To start typelist processing, other templates typically pick up the Types<...>::List type. This allows for LISP-style list processing, with a pattern match on either Node<TY,TYPES> or the type Nil to terminate recursion. In C++ template metaprogramming, "pattern match" is done by partial template specialisations (the compiler will pick up and thus match the template parameters). A type definition acts like a variable declaration in regular programming. Because such a "declaration" can't be changed after the fact, effectively this is a flavour of functional programming; the execution environment is the compiler, and evaluation is set off by some template instantiation.
See also
TypeList_test
TypeListManip_test
TypeSecManip_test
function.hpp
tuple-helper.hpp
variadic-helper.hpp

Definition in file typelist.hpp.

Namespaces

namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::meta
 

Typedefs

using NilNode = Node< Nil, Nil >
 

Classes

struct  Nil
 »Empty« mark More...
 
struct  Node< H, T >
 Type list with head and tail; T ≡ Nil marks list end. More...
 
struct  Types< T, TS... >
 
struct  Types<>
 

Class Documentation

◆ lib::meta::Nil

struct lib::meta::Nil
Class Members
typedef Nil List
+ Collaboration diagram for Nil:

◆ lib::meta::Node

struct lib::meta::Node
Class Members
typedef Node List
typedef H Head
typedef T Tail
+ Collaboration diagram for Node< H, T >:

◆ lib::meta::Types< T, TS... >

struct lib::meta::Types< T, TS... >
Class Members
typedef List > List
typedef Types Seq
+ Collaboration diagram for Types< T, TS... >:

◆ lib::meta::Types<>

struct lib::meta::Types<>
Class Members
typedef Nil List
typedef Types<> Seq
+ Collaboration diagram for Types<>: