|
|
@ -6,24 +6,36 @@ |
|
|
|
|
|
|
|
namespace exposer { |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
// REF: http://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html
|
|
|
|
|
|
|
|
//template <typename T>
|
|
|
|
//struct Exposer {
|
|
|
|
// static T ptr;
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//template <typename T>
|
|
|
|
//T Exposer<T>::ptr;
|
|
|
|
//
|
|
|
|
//template <typename T, T Ptr>
|
|
|
|
//struct ExposerImpl {
|
|
|
|
// static struct Factory {
|
|
|
|
// Factory() { Exposer<T>::ptr = Ptr; }
|
|
|
|
// } factory;
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//template <typename T, T Ptr>
|
|
|
|
//typename ExposerImpl<T, Ptr>::Factory ExposerImpl<T, Ptr>::factory;
|
|
|
|
|
|
|
|
//template <typename T>
|
|
|
|
//constexpr T fetch();
|
|
|
|
|
|
|
|
//template <typename T, T Val, int Flag>
|
|
|
|
template <typename T, T Val, typename Unique> |
|
|
|
struct Exposer { |
|
|
|
static T ptr; |
|
|
|
// constexpr friend T fetch<>() { return Val; }
|
|
|
|
constexpr friend T fetch(Unique) { return Val; } |
|
|
|
}; |
|
|
|
|
|
|
|
template <typename T> |
|
|
|
T Exposer<T>::ptr; |
|
|
|
|
|
|
|
template <typename T, T Ptr> |
|
|
|
struct ExposerImpl { |
|
|
|
static struct Factory { |
|
|
|
Factory() { Exposer<T>::ptr = Ptr; } |
|
|
|
} factory; |
|
|
|
}; |
|
|
|
|
|
|
|
template <typename T, T Ptr> |
|
|
|
typename ExposerImpl<T, Ptr>::Factory ExposerImpl<T, Ptr>::factory; |
|
|
|
|
|
|
|
} // namespace exposer
|
|
|
|
|
|
|
|
#define FORCIBLY_ACCESS(Class, Member, Type) \ |
|
|
@ -33,3 +45,13 @@ typename ExposerImpl<T, Ptr>::Factory ExposerImpl<T, Ptr>::factory; |
|
|
|
return T.*exposer::Exposer<Type Class::*>::ptr; \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
#define FORCE_ACCESS_VAR(Class, Member, Type, Unique) \ |
|
|
|
namespace exposer { \ |
|
|
|
struct Unique {}; \ |
|
|
|
template struct Exposer<Type (Class::*), &Class::Member, Unique>; \ |
|
|
|
constexpr Type Class::* fetch(Unique); \ |
|
|
|
Type& Class##_##Member(Class &T) { \ |
|
|
|
return T.*fetch(Unique{}); \ |
|
|
|
} \ |
|
|
|
} |
|
|
|