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.
5
votes
2answers
2k views
Unique type ID in C++
I need to have an unique ID for any type in C++ for a variant type. Is this code reliable for getting the ID? I don't care to have same ID for same type between multiple runs. Sorry for ...
2
votes
0answers
46 views
Counting words in files - follow-up 2
Previous question:
Counting words in files - follow-up
I have fixed punctuation problems in my previous code by using template, because it is easy to understand and my focus on template mechanism. ...
11
votes
3answers
1k views
Very basic tuple implementation
I've been messing with metaprogramming and variadic templates in C++, and I came up with this very primitive implementation of a tuple:
...
10
votes
1answer
2k views
JSON Serializer
Carrying on from:
Yet another C++ Json Parser
Yet another C++ Json Parser (Recursive)
All the code is available from git hub: ThorsSerializer but only reviewing a small section here.
The idea is ...
7
votes
2answers
146 views
writeln() and format() with variadic templates
I wanted to get better acquainted with variadic templates, so I decide to try to implement a function like D's writeln(), just for fun.
...
7
votes
1answer
210 views
C++ template range
From a previous question I got an answer that included some template magic (that to be blunt was mind-boggling (as I could not understand it)).
So I have been trying to achieve the same results ...
10
votes
2answers
124 views
Dynamically call lambda based on stream input: Try 2
Originally asked here: Dynamically call lambda based on stream input
The following version is based heavily on the answer provided by @iavr though I hope that I have done enough more to mkae it worth ...
6
votes
0answers
340 views
Building a good C++11 template library - compile-time checked enum array
The task is to add data or values to members of a given enum class. The compiler should check, if a value for each enum member is available, and not just default construct empty values. It is a tool ...
6
votes
1answer
182 views
Type to instance map
I needed a class where I could store an instance of any type. The goal was an interface as follows:
...
5
votes
2answers
201 views
Providing const- and non-const overloads of a strstr() implementation
In a question about reimplementing strstr(), I posted an answer. I pointed out a need for const- and non-const versions of the function, and provided ...
2
votes
1answer
250 views
Variadic template data pack strucuture designed for debug/trace log (variable-sized records)
I am currently writing this pack template to pack all the values (raw / fundamental + arrays of such, especially c-strings and ...