Name: Anonymous 2007-02-23 14:19 ID:2IMTb0If
Imagine the following scenario:
There are two different classes (A and B) defined in two different headers (with include guards and all that crap). Out of convenience, shared pointers have been typedef'd for each class.
// a.h
struct A {
typedef boost::shared_ptr<A> Ptr;
};
// b.h
struct B {
typedef boost::shared_ptr<B> Ptr;
};
Now, if the classes wants to keep shared pointers to each other we'll run into problems (include guards fight). It's possible to solve this by either using raw pointers, moving the typedefs out of the classes or (preferably) remove one of the dependencies between the classes.
What I'm wondering if it's possible to solve some other way. Thing is, I usually put the Ptr-typedefs inside the class declarations because it's nifty to always be able to just use ClassName::Ptr to get a shared pointer.
I know that there's a fundamental issue here anyway with the circle reference but the issue of cross-dependency-of-typedefined-stuff still remains even if one pointer is replaced by a weak pointer.
In before forced indentation.
There are two different classes (A and B) defined in two different headers (with include guards and all that crap). Out of convenience, shared pointers have been typedef'd for each class.
// a.h
struct A {
typedef boost::shared_ptr<A> Ptr;
};
// b.h
struct B {
typedef boost::shared_ptr<B> Ptr;
};
Now, if the classes wants to keep shared pointers to each other we'll run into problems (include guards fight). It's possible to solve this by either using raw pointers, moving the typedefs out of the classes or (preferably) remove one of the dependencies between the classes.
What I'm wondering if it's possible to solve some other way. Thing is, I usually put the Ptr-typedefs inside the class declarations because it's nifty to always be able to just use ClassName::Ptr to get a shared pointer.
I know that there's a fundamental issue here anyway with the circle reference but the issue of cross-dependency-of-typedefined-stuff still remains even if one pointer is replaced by a weak pointer.
In before forced indentation.