The if constexpr Statement
Learn how to use the if constexpr statement in template functions.
We'll cover the following...
We'll cover the following...
if constexpr in template functions
The if constexpr statement allows template functions to evaluate different scopes in the same function at compile time. Take a look at the following example, where a function template called speak() tries to differentiate member functions depending on the type:
Let’s say we compile the following lines:
The compiler will then generate a speak() ...