const vs constexpr on variables
Is there a difference between the following definitions? const double PI = 3.141592653589793; constexpr double PI = 3.141592653589793; If not, which style is preferred in C++11? Howard Hinnant I believe there is a difference. Let's rename them so that we can talk about them more easily: const double PI1 = 3.141592653589793; constexpr double PI2 = 3.141592653589793; Both PI1 and PI2 are constant, meaning you can not modify them. However only PI2 is a compile-time constant. It shall be initialized at compile time. PI1 may be initialized at compile time or run time. Furthermore, only PI2 can be