Questions tagged [template-meta-programming]

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.

Filter by
Sorted by
Tagged with
6
votes
1answer
11k views

C++ compile-time checked switch 'statement'

In the project I work on there are several places where a switch statement is used on a type enum. (I know, better to use virtual functions or a visitor pattern or something, but sometimes switching ...
3
votes
1answer
1k views

Could this deferred execution scheme be any simpler?

I've created this scheme to preserve function calls until all the arguments are available. The stub_op classes will be replaced with classes that implement a ...
7
votes
1answer
420 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: ...
3
votes
1answer
1k views

Singleton with template wrapper

So far, I've used this in a few places and it seems solid. This is what I usually do to make a singleton: ...
32
votes
1answer
6k 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 ...
2
votes
1answer
870 views

How can I improve the design of this serialization mechanism?

I'm working on caching library which is intended to work with all types of values. Values are represented as instances of value_type: ...
12
votes
1answer
4k views

Variadic function with restricted types

I am designing a class which (among other things) acts as a vertex in an undirected graph. ...
10
votes
1answer
396 views

Mixin and template-heavy code for a Silverlight clone

I've made a mock version of Silverlight in D2. It is meant to output HTML, but since I don't know HTML yet, its current output is in. HTML is not the reason I'm here, though. The goal of my project ...
5
votes
1answer
970 views

Meta-program to find square numbers

I'm new to template meta-programming and wrote some code to determine if a number is a perfect square. For example, in my program, SQUARE<1>::value and ...

1 2 3 4 5
6