Topic: explicit destructor call from template
Author: rmartin@rcmcon.com (Robert Martin)
Date: Mon, 16 Aug 1993 14:34:51 GMT Raw View
vinoski@apollo.hp.com (Steve Vinoski) writes:
>>
>>template <class T> void destroy(T* obj) {
>>
>> obj->T::~T(); // BUG confused templates
>[rest of example elided]
>BTW, note that the syntax "obj->T::~T();" suppresses the virtual
>destructor invocation mechanism. What you probably want most often in
>this situation is "obj->~T();". See page 280 of the ARM.
In cases where I have tried the ->~ notation, I have experienced
complaints by the compiler. Although the annotations to the RM on
page 280 seem to show that the syntax is allowable, and that it
represents a virtual call of the destructor, the RM itself (pg 278)
says:
"Destructors are invoked [...] (4) explicitly using the
destructor's fully qualified name."
The commentary following this statement shows a destructor being
called via p->X::~X();
Does anybody know what the actual rule is? Can a destructor be called
without a qualified name?
--
Robert Martin | Design Consulting | Training courses offered:
Object Mentor Assoc.| rmartin@rcmcon.com | Object Oriented Analysis
2080 Cranbrook Rd. | Tel: (708) 918-1004 | Object Oriented Design
Green Oaks IL 60048 | Fax: (708) 918-1023 | C++