M
marcus hall
Now that g++ is complaining about offset-of() applied to a class, it
raises the issue of how to implement a "container-of" concept in C++.
Specifically, I have a pointer to a class that is aggregated into an
outer class. I know the type of the outer class, and a pointer to the
member of that class. What is the preferred method of producing a pointer
to the outer class?
class A {
public:
...
class B _b;
};
A _a;
I have &_a._b and I want to get &_a.
Is the only legal way now to store a "class A *" within class B?
Marcus Hall
(e-mail address removed)
raises the issue of how to implement a "container-of" concept in C++.
Specifically, I have a pointer to a class that is aggregated into an
outer class. I know the type of the outer class, and a pointer to the
member of that class. What is the preferred method of producing a pointer
to the outer class?
class A {
public:
...
class B _b;
};
A _a;
I have &_a._b and I want to get &_a.
Is the only legal way now to store a "class A *" within class B?
Marcus Hall
(e-mail address removed)