6

有没有办法将 BOOST_HANA_ADAPT_STRUCT 宏用于从基本结构继承的结构而不重复基本结构的访问器?

现在我有类似于以下示例的内容:

namespace hana = boost::hana;
namespace ns {
    struct Person {
       std::string name;
       int age;
    };
}
BOOST_HANA_ADAPT_STRUCT(ns::Person,
    name,
    age
);

namespace ns {
    struct Employer : Person {
       std::string company;
    };
}
BOOST_HANA_ADAPT_STRUCT(ns::Employer,
    name, // duplication
    age,  // duplication
    company
);
4

0 回答 0