How to use BOOST_FUSION_ADAPT_STRUCT with substructures?

For example, suppose I have the following structure / substructure 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 to use BOOST_FUSION_ADAPT_STRUCT on employee_rec ?

+4
source share
1 answer

Adapt both structures, it also helps to break down your grammar into all types of structures (the rule for the address and the rule for the 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) ) 
+6
source

All Articles