Template Metaprogramming Practice Codes

Ex.   Code   What I learned?
1   simplest metaprogram with type_traits   How std::is_pointer<T>::value works. How to take template argument T and strip off any pointer if it has one. Compile-time if-else.
2   dynamic type-dispatch   A dispatch mechanism in C++ to dynamically select and execute type-specific kernel implementations for different scalar types using variadic macros.

I will add more examples in time.

References




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Exploring Type Erasure as a Design Pattern: A Generic Materials Solver
  • GoF Design Patterns: A Brief Overview
  • Exploring Policy-Based Design: A Customizable Message Logger in C++
  • Just-In-Time Compiled CUDA Kernel
  • GPU Practice Codes