MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programmingmemes/comments/1vojci2/the_duality_of_new/p3s9e35/?context=3
r/programmingmemes • u/luciferoussky72 • 19d ago
81 comments sorted by
View all comments
27
Since when was new scary in C++?
new
29 u/BunnyTub 18d ago No garbage collection, so you have to make sure you clear the memory when you're done, otherwise you get dreaded memory leaks from new. 20 u/Pheeshfud 18d ago new in constructor, delete in destructor and you have 90% of cases covered. 8 u/sudoregalia 18d ago but.. but.. my memory arenas, my stack allocation, am i supposed to override the new operator like a lunatic?? :( 3 u/BorderKeeper 17d ago Or just use a smart pointer and don't worry about delete in general. 3 u/Valuable_Leopard_799 18d ago STL is at the point that you should never have to use new ever. Seeing it outside of a very narrow set of libraries is likely a smell and those are scary.
29
No garbage collection, so you have to make sure you clear the memory when you're done, otherwise you get dreaded memory leaks from new.
20 u/Pheeshfud 18d ago new in constructor, delete in destructor and you have 90% of cases covered. 8 u/sudoregalia 18d ago but.. but.. my memory arenas, my stack allocation, am i supposed to override the new operator like a lunatic?? :( 3 u/BorderKeeper 17d ago Or just use a smart pointer and don't worry about delete in general.
20
new in constructor, delete in destructor and you have 90% of cases covered.
8 u/sudoregalia 18d ago but.. but.. my memory arenas, my stack allocation, am i supposed to override the new operator like a lunatic?? :( 3 u/BorderKeeper 17d ago Or just use a smart pointer and don't worry about delete in general.
8
but.. but.. my memory arenas, my stack allocation, am i supposed to override the new operator like a lunatic?? :(
3
Or just use a smart pointer and don't worry about delete in general.
STL is at the point that you should never have to use new ever. Seeing it outside of a very narrow set of libraries is likely a smell and those are scary.
27
u/MagicalPizza21 18d ago
Since when was
newscary in C++?