Awesome little header, is there a way to access a private member that is a reference?
It's not listed as a limitation, but I could not find a test for it.
I did some experiments in g++ but I got some compilation errors, for example:
struct A {
public:
A() : foo(99), bar(foo) {}
private:
int foo;
int& bar;
};
ACCESS_PRIVATE_FIELD(A, int, bar) // error: cannot create pointer to reference member
ACCESS_PRIVATE_FIELD(A, int&, bar) // error: cannot declare pointer to 'using Alias_PrivateAccessTag0 = int&' {aka 'int&'}
int& x = access_private::bar(a);
Awesome little header, is there a way to access a private member that is a reference?
It's not listed as a limitation, but I could not find a test for it.
I did some experiments in g++ but I got some compilation errors, for example: