Warnings

The tricks involved in this presentation may exploit definitions found in the standard, or they may merely be things that aren’t commonly known. Either way, in 99.9999% of the cases where you wonder if you need to use them, you definitely don’t.

The people who actually need them know with certainty that they need them, and don’t need an explaination about why

Python Guru Tim Peters

This presentation is designed to show the effects of:

Different language features interacting

The programmer having complete control over how an individual segment of memory is used

Manipulating the build system (such as the preprocessor)

It is NOT meant to demonstrate things that should be used for anything more than messing around and learning. If you use these in production code, you will be REDACTED.

Harmless

String Concatenation

Two string literals, placed “next to” each other, will be treated as one:

Unions

Unions are a C++ construct that seem to be horribly misused. Their purpose is to save memory, by placing several variable types in the same block of memory. The behavior of writing to one type and reading from another is undefined.

Loop classes

Because of how structures are declared, it’s also possible to create one in the same place. This can be used to create several variables with different types, which is otherwise impossible while keeping their scope limited to the for loop.

Templates

Templates are a way to write code that can be adapted to work on any type, such as containers. std::vector is a template, so vector<T> means roughly vector of some type T The syntax for declaring a template is: