User Tools

Site Tools


2015:compile-time_computations_in_c_14

This is an old revision of the document!


Back to 2015-proposals

Title: Compile-time Computations in C++14
Proposer: Peter Sommerlad
Type: Tutorial
Duration: 90 mins
Description:
While in the past C++ provided compile-time computation only very clumsily using templates with value parameters, C++11 introduced the constexpr keyword and allows functions and constants to be computed at compile time. It even introduced a new category of types “Literal Types” that can be used in such compile-time computations. C++14 further relaxed the restrictions on constexpr functions to allow all reasonable statements that make sense at compile time. As long as at compile-time the computation path of a function remains within these limitations regular C++ can be used in constexpr function. However, when exploring/exploiting the compile-time computation features, one will recognize there are limitations and compile-time impacts can be really severe.

The tutorial covers many kinds of compile-time computations available in C++14, from constexpr functions and constants, literal types, variable templates, up to variadic templates using std::integer_sequence for string processing. It also gives a glimpse of the potential future standardized features, like user-defined-literal template operators for string literals. The tutorial also shows, where C++14 still has limitations in supporting compile-time computations and what you might need to do, to sidestep them.



2015/compile-time_computations_in_c_14.1414566977.txt.gz · Last modified: 2016/06/11 14:05 (external edit)