Implement Compile Time Peano Numbers – A Primer in C++ Template Metaprogramming

Like
Like Love Haha Wow Sad Angry
2

Fundamentals

Function on Types

We all know that C++ templates can receive types as “parameters”. In the same spirit we could can “return values”s, so that we can form a function. The basic paradigm is the following:

template<class T>
struct Computed {
  using type = T;
}

In this way we constructed a type level function named Computed, with one parameter  and result the parameter itself. We use the function as Computed<float>::type, the result being float itself.

Continue reading “Implement Compile Time Peano Numbers – A Primer in C++ Template Metaprogramming”

Like
Like Love Haha Wow Sad Angry
2