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{}; };
String 'static constexpr StaticObject outer {};' gives me an error:
'expression was not evaluated by a constant'
Followed by
Note: failure caused by calling undefined function or not declared "constexpr"
Note: see "Parent :: StaticObject :: StaticObject"
As far as I can tell, all the functions used here are defined and declared as constexpr. Am I missing something, or is it a compiler error?
source share