For instance, suppose I have the following struct/sub-struct definition:
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;
};
How should I use BOOST_FUSION_ADAPT_STRUCT
on employee_rec
?
Adapt both structs, it also helps to break your grammars down into each struct types too, (a rule for address and a rule for employee which contains the address rule)
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)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.