I have the following code:
struct Literal
{
int val;
constexpr Literal(int const& val) : val(val) {}
constexpr Literal(Literal const& rhs) : val(rhs.val) {}
};
struct Parent
{
struct StaticObject
{
Literal const zero;
constexpr StaticObject() :zero(0) {}
};
static constexpr StaticObject outer{};
};
The line 'static constexpr StaticObject outer{};' gives me the error:
'expression did not evaluate to a constant'
This is followed by
note: failure was caused by call of undefined function or one not declared 'constexpr'
note: see usage of 'Parent::StaticObject::StaticObject'
As far as I can tell, all the functions being used here are both defined and declared constexpr. Am I missing something, or is this a compiler bug?