|
Boost : |
From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-30 10:59:01
Ross Smith wrote:
> In that case I must have completely missed your point. I thought you
> were complaining about not being able to instantiate a smart pointer on
> an incomplete type.
I was.
> If you were, I don't think that's a reasonable thing
> to expect to be able to do.
Recursive data structures are natural. Being able to manage them
with smart pointers is a requirement.
The most trivial case proves that:
template <class T> class SLNode {
T data;
smart_ptr<SLNode<T> > next;
};
This is a singly linked list using a smart pointer.
Obviously, because it is recursive, it cannot possibly
be complete at the point 'smart_ptr<SLNode<T> > next;'
is seen, so it is absolutely essential, no ifs, buts,
or excuses, to be able to 'instantiate' a template
with an incomplete type, provided of course that its
definition will work with an incomplete type.
Smart pointer class definitions usually work
with incomplete types. They have pointers to T in them,
and there is no requirement T be complete for the
class to be complete. So it cannot be required, per se,
for template 'instantiation' either:
template<class T>
class smart_ptr {
T *ptr;
public:
//methods
};
-- John (Max) Skaller, mailto:skaller_at_[hidden] 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk