Re:A Usable C++ Dialect That Is Safe Against Memory Corruption
by Kenji on Thursday March 15, 2018 @02:44PM
(#16595465)
This is basically how I program C++. Except that I try to avoid the 'new' keyword too by std::make_unique and std::make_shared. This way there are literally zero 'new' and 'delete' or 'malloc' or 'free' calls in your program.
[ Parent
| on HN ]
Re:A Usable C++ Dialect That Is Safe Against Memory Corruption
by beached_whale on Thursday March 15, 2018 @03:25PM
(#16595813)
I would try to go further and wrap them in a class to hide the heap usage and expose the valid uses in the interface. Then it reads like a value and walks like one too. Unless I need virtual inheritance I guess.
Re:A Usable C++ Dialect That Is Safe Against Memory Corruption
by ape4 on Thursday March 15, 2018 @03:09PM
(#16595672)
Likewise, I avoid -> if possible.
Re:A Usable C++ Dialect That Is Safe Against Memory Corruption
by saagarjha on Thursday March 15, 2018 @03:19PM
(#16595750)
Like, the operator ->? Why, and what do you use instead?
Re:A Usable C++ Dialect That Is Safe Against Memory Corruption
by kolpa on Thursday March 15, 2018 @03:46PM
(#16595983)
You could use ".get()." instead of "->", but I don't see how that helps.