例如,假设我有以下结构/子结构定义:
struct address_rec
{
std::string m_street;
std::string m_state;
unsigned m_zip;
};
struct employee_rec
{
std::string m_name;
address_rec m_address;
};
我应该如何在BOOST_FUSION_ADAPT_STRUCT
上使用employee_rec
?
答案 0 :(得分:6)
调整两个结构,它也有助于将语法分解为每个结构类型,(地址规则和包含地址规则的员工规则)
struct address_rec
{
std::string m_street;
std::string m_state;
unsigned m_zip;
};
BOOST_FUSION_ADAPT_STRUCT(
::address_rec,
(std::string, m_street)
(std::string, m_state)
(unsigned, m_zip)
)
struct employee_rec
{
std::string m_name;
address_rec m_address;
};
BOOST_FUSION_ADAPT_STRUCT(
::employee_rec,
(std::string, m_name)
(address_rec, m_address)
)