The accepted answer in literal class compile error with constexpr constructor and function (differ vc, g++) shows that in C++14 there is a difference in the way constexpr int A::a() and constexpr A::a() const can be used. i.e. constexpr on a member function does not imply that the function does not change the object it acts on.
The given example is:
struct A {
constexpr A() {}
constexpr int a() {return 12; }
constexpr int b() const {return 12; }
};
int main()
{
constexpr A a;
// DOES NOT COMPILE as a() is not const
// constexpr int j = a.a();
const int k = a.b(); // Fine since b() is const
}
To me the constexpr on a() seems useless.
Is there a concrete use for constexpr on a non-const member function?