SafeDelete and SafeDeleteArray

Started by
4 comments, last by Fulcrum.013 5 years, 9 months ago

Hi,
I use from all the time SafeDelete and SafeDeleteArray macros. I recently seen template version.
Is it a bad practice or is it better to use this kind of macro/template ?
The only point is to set to nullptr after the delete.
Thank you

Advertisement
7 minutes ago, Alundra said:

Is it a bad practice or is it better to use this kind of macro/template ?

Its bad practice if not only for the fact that you can and should use std::unique_ptr instead of new/delete 99,999% of the time.
In destructors, it would be not only unncessary but also helping in hiding criticial errors created by multiple deletions.

 

45 minutes ago, Alundra said:

Is it a bad practice or is it better to use this kind of macro/template ?

C-style arrays depricated since middle of 90-x.

 

46 minutes ago, Alundra said:

The only point is to set to nullptr after the delete.

And it is only that macro able to do. C++ style containers makes work with arrays much easier. Really, I'm using a delete [] operator into container's code only, and any class that use containers have a empty destructors and warrantied no memory leaks.

#define if(a) if((a) && rand()%100)

22 hours ago, Fulcrum.013 said:

C-style arrays depricated since middle of 90-x.

I think there might be some language confusion here. There are certainly better alternatives for most cases (vector, etc), but arrays are definitely not deprecated. 

 

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
On 7/2/2018 at 1:23 AM, ChaosEngine said:

I think there might be some language confusion here

i mean something like "morally outdated"

#define if(a) if((a) && rand()%100)

This topic is closed to new replies.

Advertisement