Is it possible to smooth out an adaptive base class as if it were a member?
First up is a sample documentation, side by side with a new case:
#include <boost/fusion/adapted/struct/adapt_struct.hpp> #include <boost/fusion/include/adapt_struct.hpp> struct employee{ std::string name; int age; }; BOOST_FUSION_ADAPT_STRUCT( employee, (std::string, name) (int, age)) struct employee2 : std::string{ int age; }; BOOST_FUSION_ADAPT_STRUCT( employee2, (std::string, name) ??? (int, age)) int main(){}
What should I put in a string with ??? .
Currently, the only solution I have found is to do this, but 1) I have to execute all the getter and setter functions 2) it seems to be crowded.
#include <boost/fusion/adapted/adt/adapt_adt.hpp> struct employee2 : std::string{ int age; void set_base(std::string const& age_){std::string::operator=(age_);} std::string const& get_base() const{return static_cast<std::string const&>(*this);} void set_age(int const& age_){age = age_;} int const& get_age() const{return age;} }; BOOST_FUSION_ADAPT_ADT( employee2, (std::string, std::string, obj.get_base(), obj.set_base(val)) (int, int, obj.get_age(), obj.set_age(val)) )
source share