From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-05-19 10:21:17
On Mon, May 19, 2008 at 8:02 AM, Emil Dotchevski
>> Am Sonntag 18 Mai 2008 19:28:42 schrieb Giovanni Piero Deretta:
>> > On Sun, May 18, 2008 at 3:52 PM, Maik Beckmann
>> > I'm not a guru, but Instead of a vector<shared_ptrs<T> >, I'have used
>> > a shared_ptr <vector<T> > to implement recursive data structures. A
>> > clone pointer would work even better.
>> Giovanni, very nice!
> A standard conforming compiler is allowed to reject std::vector<T> for
> incomplete T.
Are you sure about it? I think that the standard says (I do not have
it, I'm looking at the last draft):
"In particular, the effects are undefined in the
following cases: if an incomplete type is used as a template argument when
instantiating a template component."
I'm not a language lawyer, but does boost::shared_ptr<vector<T> >
count as an instantiation?
The definition of (implicit) template instantiation in the draft I
have (14.7.1) says:
"Unless a class template specialization has been explicitly
instantiated (14.7.2) or explicitly specialized (14.7.3), the
class template specialization is implicitly instantiated when the
specialization is referenced in a context that requires a
completely-deï¬ned object type or when the completeness of the class
type affects the semantics of the program. "
In particular the example in this section shows that creating a
pointer to a template specialization does not require an
Boost shared_ptr explicitly allows its parameter to be incomplete, so
it will definitely not be used in a context that requires a completely
defined object. The boost::shared_ptr constructor is another story of
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk