constexpr in C++ 11 and C++ 14

In the previous post, we were talking about the constexpr keyword in modern C++. It was added to the C++ 11 standard, but in C++ 14, it got a very nice addition. In particular, you can do more in constexpr functions now. Consider the following program that wants to pre-compute a factorial of 5. #include <iostream> … Continue reading “constexpr in C++ 11 and C++ 14”

constexpr in C++

The constexpr keyword is a relatively new addition to C++. You need to use the C++11 standard in order to compile the following programs: g++ -std=c++11 test.cpp Let’s examine what the keyword is about. There’s no difficulty to split it into words to get the meaning: constant expression. In practice, constant expression means that the … Continue reading “constexpr in C++”