6

Is there a way to use the BOOST_HANA_ADAPT_STRUCT macro for a struct that inherits from a base struct without repeating the accessors of the base struct ?

Right now I have something similar to the following example:

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
);
JE42
  • 4,881
  • 6
  • 41
  • 51
  • 3
    To make this possible, we would need to be able to get a list of base classes from a type or have a trait or macro that specify the base classes. – Jason Rice Apr 11 '17 at 00:06
  • 3
    There is no way to do that in Hana right now, but I filed [this feature request](https://github.com/boostorg/hana/issues/339) for you. – Louis Dionne Apr 23 '17 at 19:36

0 Answers0