Top "Template-meta-programming" questions

Template meta-programming is a meta-programming technique in which templates are used by a compiler to generate temporary source code, which is merged by the compiler with the rest of the source code and then compiled.

How to build a compile-time key/value store?

I have a problem where I need to map an integer at compile time to another integer. Basically, I need …

c++ template-meta-programming
Does anyone use template metaprogramming in real life?

I discovered template metaprogramming more than 5 years ago and got a huge kick out of reading Modern C++ Design but …

c++ templates template-meta-programming
Metaprogramming with std::is_same

Is it possible to do something like the following that compiles without template specialization? template <class T> class …

c++ template-meta-programming
c++ power of integer, template meta programming

I want to make a function which returns a power of integer. Please read the fmuecke's solution in power of …

c++ templates c++11 template-meta-programming
Compile-time constant id

Given the following: template<typename T> class A { public: static const unsigned int ID = ?; }; I want ID to …

c++ templates template-meta-programming
Checking a member exists, possibly in a base class, C++11 version

In https://stackoverflow.com/a/1967183/134841, a solution is provided for statically checking whether a member exists, possibly in a subclass …

c++ c++11 final template-meta-programming typetraits
What are the coolest examples of metaprogramming that you've seen in C++?

What are the coolest examples of metaprogramming that you've seen in C++? What are some practical uses of metaprogramming that …

c++ templates metaprogramming template-meta-programming
How do I use std::enable_if with a self-deducing return type?

C++14 will have functions whose return type can be deduced based on the return value. auto function(){ return "hello world"; } …

c++ template-meta-programming typetraits c++14 enable-if
C++ iterate into nested struct field with boost fusion adapt_struct

Two stackoverflow answers suggest the approach using fusion adapt_struct to iterate over struct fields. The approach looks nice. However, …

c++ reflection introspection template-meta-programming boost-fusion
Getting the type of a member

NOTE: This question was originally asked way back in 2012. Before the decltype specifier was fully implemented by any major compilers. …

c++ templates template-meta-programming c++03