From: Mathias Gaunard on
On 10 d=E9c, 13:40, Taras Shevchuk <sh...(a)gala.net> wrote:

> 2. in case if T is base class then "this->~T();" will partially delete
> object.

Not if the destructor is virtual.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Mathias Gaunard on
On 10 d=E9c, 11:32, Goran <goran.pu...(a)gmail.com> wrote:

> Destructor should almost never be called explicitly.

It is perfectly fine to call it yourself, you just have to be aware
you need to provide a fallback solution in case of exceptions. Usage
of nothrow default constructor or move constructors can be quite
helpful, for example.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Goran on
On Dec 12, 11:12 am, Mathias Gaunard <loufo...(a)gmail.com> wrote:
> On 10 d=E9c, 11:32, Goran <goran.pu...(a)gmail.com> wrote:
>
> > Destructor should almost never be called explicitly.
>
> It is perfectly fine to call it yourself, you just have to be aware
> you need to provide a fallback solution in case of exceptions. Usage
> of nothrow default constructor or move constructors can be quite
> helpful, for example.

Of course var.~TYPE() can be made to work, I never tried to say that.
My point was that there is almost no reason to do it. I showed some
reasons, and of course tried to dismantled them ;-).

I was more going with this: "you just need..." part is scary,
especially if asked by someone with less experience and/or
understanding of the issues.

Goran.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Mathias Gaunard on
On 13 d�c, 09:29, Goran <goran.pu...(a)gmail.com> wrote:

> Of course var.~TYPE() can be made to work, I never tried to say that.
> My point was that there is almost no reason to do it. I showed some
> reasons, and of course tried to dismantled them ;-).

Here is a good reason: you want to use a specific part of memory to
store objects of different types.
boost::variant, for example.


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]