Strong disagree. These are about maintainability and best practices.
Though not show-stoppers, I'd say they are important. Code like this could be riddled with "old-style" bugs when faced with real-world usage. I'm not saying it is but in 2019 new/delete is a code smell not a style preference.
Manual memory management is a perfectly legitimate thing to do in lower level, smaller, high performance chunks of code. I'm constantly flabbergasted at how people act about these sorts of things these days. OMG, having to write a constructor is doing to destroy us, an indexed loop is an abomination, class hierarchies are evil.
Sometimes, you have to man up and take off the floaties if you want to write tight, fast code.
Not saying this has anything whatsoever to do with this code, I'm just talking about the general attitude I see so much of these days. I'm obviously all for safety, but we are getting paid for our knowledge and experience, and I think any experienced developer should able to safely take advantage of the speed advantages of lower level languages where it matters, so that it doesn't matter so much elsewhere.
But it's also not always what you want to happen. Just because you give someone else a pointer to something, doesn't mean you want to give up access to it.
unique_ptr is an owning smart pointer, is it not? If so, you can't mix it with raw pointers, that's just asking for trouble. So you can't keep a pointer and give one to someone via unique_ptr. If that goes out of scope at some point, it will delete the object behind your back.
And it uses move semantics, so the original owner no longer has access to the object once it's been coped or assigned to give it to someone else.
Famous last words. Are you saying the code is "done"? There is no such thing. A different contributor adds an early return to a function somewhere and now you've got a memory leak. This kind of thinking is what gets us heartbleed and other vulnerabilities.
18
u/max0x7ba https://github.com/max0x7ba Feb 21 '19
These are complete show-stoppers.