Sep. 2nd, 2008

zwol: stylized sketch of a face in profile (Default)

Is it possible in C++ to declare and initialize a pointer-to-member that points to a data member of a data member? Concretely, given

struct A { int x; int y; };
struct B { A i; A ii; A iii; A iv; };

I would like to be able to do something like this:

TYPE piix = INITIALIZER<B, ii, x>;
...
B b;
int x_within_ii = b.*piix;

Is this possible? If so, exactly how do you write TYPE and INITIALIZER? If not, why the hell not?

April 2017

S M T W T F S
      1
2345678
9101112131415
16171819 202122
23242526272829
30      

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 3rd, 2026 02:24 pm
Powered by Dreamwidth Studios