On 2005-06-25 14:32:24 +0100, "Victor Bazarov" <> said:
> verec wrote:
>> [... forward-declaration doesn't work when instantiating templates...]
>> Apart from tinkering with envelope<T> so that it doesn't
>> require a complete type (which may or may not be possible),
>> anyone sees a way out of this conundrum?
[...]
> No matter how you move things around, you're faced with something
> that would require an instantiation of a template from a type that
> hasn't been defined yet.
First, thank you Victor, for taking the time to understand the issue.
> Are you sure that you need to pass an "envelope" to the function
> of your 'drawable' class?
Well ... yes. The choices I seem to be left with are:
1. redesign the code so as to eliminate circular dependencies.
2. use raw pointers in at least parts of the code
3. rework envelope
1. is next to impossible. I'm porting, not redesigning a whole
system from scratch. That would completely change the nature
of the project. Given that the port itself, without redesign,
is already a huge task, choosing this path would mean the
project death. I simly do not have the 6 years ahead of me
to complete it
2. If #3 fails, I will very reluctantly pursue this path.
3. Seems the least bad compromise. I tried:
--- gcdata.hpp ---
template <typename T> struct Test {
T * body ;
Test(T * q = 0) : body(q) {}
} ;
struct device ;
// typedef envelope<device> Device ;
typedef Test<device> TDevice ;
struct gcdata {
// Device dev ;
TDevice tdev ;
} ;
typedef envelope<gcdata> GCData ;
And this does compile, probably because the Test<T> template only
deals with T * and never with T's. But I fear that the conversion
of envelope<T> might not be as simple ...
Many thanks for your time
--
JFB