Is is_constexpr possible in C++11?

I once wrote it (EDIT: see below for limitations and explanations). From https://stackoverflow.com/a/10287598/34509 : template<typename T> constexpr typename remove_reference<T>::type makeprval(T && t) { return t; } #define isprvalconstexpr(e) noexcept(makeprval(e)) However there are many kinds of constant expressions. The above answer detects prvalue constant expressions. Explanation The noexcept(e) expression gives false iff e contains a potentially … Read more

const vs constexpr on variables

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 … Read more

Why do constant expressions have an exclusion for undefined behavior?

The wording is actually the subject of defect report #1313 which says: The requirements for constant expressions do not currently, but should, exclude expressions that have undefined behavior, such as pointer arithmetic when the pointers do not point to elements of the same array. The resolution being the current wording we have now, so this … Read more