有了这个代码
#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;
}
我收到以下编译错误
/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)>{};
关于这个问题,看来我正在解决这个核心问题,但是我想检查一下我的理解。
具体来说,我在打吗
当前文本中未指定的订单依存关系
什么时候初始化了我typedef
的?还是有关inner的其他问题导致此编译错误?variant
Inner
struct
这不依赖于任何东西constexpr
,因此它与CWG1360不同,但是可以肯定的是,它利用不可能同时将嵌套类作为其包含类的完整类上下文并具有嵌套类在包含类中比其定义晚完成。最好的场所也许是CWG2335,为此提出了一般(长期)建议,即类中的实际依赖关系应通过类似实例化的机制进行跟踪。像你这样的例子问这样的处理跨类。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句