8
Compile-Time Programming
C++ has the ability to evaluate expressions at compile time, meaning that values are already calculated when the program executes. Even though metaprogramming has been possible since C++98, it was initially very complicated due to its complex template-based syntax. With the introduction of constexpr
, if constexpr
, and recently, C++ concepts, metaprogramming has become much more similar to writing regular code.
This chapter will give you a brief introduction to compile-time expression evaluations in C++ and how they can be used for optimization.
We will cover the following topics:
- Metaprogramming using C++ templates and how to write abbreviated function templates in C++20
- Inspecting and manipulating types at compile ...
Get C++ High Performance - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.