schaumb / access_private_20

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

Get the memptr/funptr exact defined class #10

Closed schaumb closed 6 months ago

schaumb commented 6 months ago

The exact class is hidden if you want to access some function/member at any base class.

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

This member pointer resolved as unsigned char std::__detail::__variant::_Variant_storage_alias<double, std::string_view>::* and not unsigned char VD::*. Currently, it cannot be queried.

It can be a nice feature that gets the exact member pointer's class:

template struct access_private::type_access_at<&VD::_M_index>;

using base_class = access_private::type_accessor_at<"_M_index">;
using result_class = access_private::type_result_at<"_M_index">;
schaumb commented 6 months ago

Done.