What does the C++11 iso standard say about such an expression :
class MyClass
{
public:
constexpr int test()
{
return _x;
}
protected:
int _x;
};
_x is a non-const used in a constexpr : will it produce an error, or will the constexpr be simply ignored (as when we pass a non-const parameter) ?
It’s perfectly fine, though somewhat useless:
Since
MyClassis an aggregate, value-initializing it like that will value-initialize all members, so this is just zero. But with some polish this can be made truly useful: