With this code
#include <boost/variant.hpp>
#include <string>
struct Outer
{
struct StateA
{
std::size_t index = std::string::npos;
};
struct StateB {};
using State = boost::variant<StateA, StateB>;
struct Inner
{
State state = StateB{};
};
};
int main() {
Outer o;
(void)o;
}
I get the following compilation error
/usr/include/boost/variant/variant.hpp:1301:17: required from ‘class boost::variant<Outer::StateA, Outer::StateB>’
inner_class.cpp:18:30: required from here
/usr/include/boost/type_traits/has_nothrow_constructor.hpp:27:84: error: constructor required before non-static data member for ‘Outer::StateA::index’ has been parsed
template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{};
Referring to this question, it would seem that I'm hitting this core issue, but I wanted to check my understanding.
Specifically, am I hitting
an order dependency that is not specified in the current text
when my typedef
of a variant
is initialised in Inner
? Or is there something else about inner struct
s that causes this compilation error?