schaumb / access_private_20

Access private members and statics of a C++ class
MIT License
8 stars 2 forks source link

Cannot able to get private member behind base class #9

Open schaumb opened 6 months ago

schaumb commented 6 months ago

example:

using VD = std::variant<double, std::string_view>;
template struct access_private::access<&VD::_M_index>; 

... 

VD vd;
accessor<"_M_index">(vd); // fail, because this member is hidden behind private base class
schaumb commented 6 months ago

Currently, it can be a workaround if you know the exact type (#10 if you don't):