4

例如,假设我有以下结构/子结构定义:

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

4

1 回答 1

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)
)
于 2012-11-26T13:33:40.947 回答