Teaching Old Compilers New Tricks: Transpiling C++17 to C++11

Speaker: Tony Wasserka

Audience level: Intermediate | Advanced


Recent compiler versions enable us to leverage new C++17 features such as structured bindings and fold expressions to great effect on the expressiveness and type safety of our software - but what if we're stuck on an old compiler that barely supports C++11? Is patience for a toolchain update our only hope of new features?

Enter clang-from-the-future, a transpiler that turns C++17 programs into equivalent C++11 source code. To achieve this, CTFT rewrites new language features based on the program's abstract syntax tree and provides drop-in implementations for standard library additions. Used as a preprocessing step, this allows any compiler with C++11 support to compile a subset of C++14/17 programs.

In my talk, I will show how specifically this works, what problems I had to address in practice, and what's left to be done in the future.