6
기본 클래스가 멤버 인 것처럼 기본 클래스를 융합 할 수 있습니까?기본 클래스를 융합 할 수 있습니까?
먼저이 문서의 예입니다, 나란히 새로운 케이스 : 나는 ???
과 라인에 넣어해야합니까
#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(){}
.
현재 내가 찾은 유일한 해결책은이 작업을 수행하는 것입니다. 그러나 1) 모든 구성원을 게터 및 설정 기능으로 만들어야합니다. 2) 과도한 것 같습니다.
#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))
)