【发布时间】:2022-01-20 07:15:50
【问题描述】:
我可以将“BOOST_FUSION_ADAPT_STRUCT”与具有std::vector 的结构类型“opt”一起使用吗?std::vector 使用结构类型A 进行实例化,如下所示。
只是想知道是否允许这样做,或者我在下面的用例中尝试将BOOST_FUSION_ADAPT_STRUCT 与包含std::vector 的结构一起使用时在这里犯了一些错误?
struct NameValue
{
NameValue(const std::string& _e) :e(_e)
{};
std::string e;
};
struct A
{
std::string name;
boost::optional<bool> value;
std::string path;
std::string type;
};
BOOST_FUSION_ADAPT_STRUCT(A,
(std::string, name)
(boost::optional<bool>, value))
(std::string, path)
(std::string, type))
struct opt : public NameValue
{
opt() : NameValue("One")
{};
std::vector<A> s;
};
BOOST_FUSION_ADAPT_STRUCT(opt,
(std::vector<A>, s))
【问题讨论】:
-
为什么你认为
std::vector会很特别? -
@Jarod42 - 这里的用例是从特定结构继承的结构中的向量。在我进一步调试我的问题之前,我想检查一下上面共享的 sn-p 是否有问题