Boost logo

Boost Users :

Subject: [Boost-users] Cyclic includes when using smart pointers.
From: Jared Lee Richardson (jaredr26_at_[hidden])
Date: 2009-03-31 11:41:26


Hey, I'm having trouble with cyclic includes in a project I'm working
on. This is my first attempt at a project that heavily uses boost,
and specifically, smart pointers.

I have the following situation, simplified down.

Header file 1:

class Test1
{
vector<Test2Ptr> mTest2Objects;
};

typedef boost::shared_ptr<Test1> Test1Ptr;

Header file 2:

class Test2
{
vector<Test1Ptr> mTest1Objects;
};

typedef boost::shared_ptr<Test2> Test2Ptr;

Now normally I'd get around this easily by doing a forward
declaration, but I can't do that with a smart pointer definition. How
can I work around this? So far I have found ways to work around the
above(Since that's not precisely what I'm doing), but when I start
inlining functions it will become very difficult to work around.

Obviously something is wrong with my include structure or how I am
going about this, but I don't know what... Any help? Is there a way I
can forward-declare smart pointers? How are complicated cyclic
includes usually resolved, if forward declares aren't enough(i.e.,
inline files)?

Thanks, Jared


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net