3 ms·
Good C++ code shouldn't throw around heap allocations, shared or otherwise. Smart pointers are like duct tape, they help keeps things together but most of the t
by josefx 6y ago
Good C++ code shouldn't throw around heap allocations, shared or otherwise. Smart pointers are like duct tape, they help keeps things together but most of the time there are better solutions. Your complaint about void will be noted once you fix your programs ownership semantics.
Note: Any negative reactions to smart pointers on my side may be fueled by a disturbing amount of cargo culting that I had to witness since their inclusion in the standard.
- zabzonk 6y ago> Your complaint about void will be noted By whom? > once you fix your programs ownership semantics. How do you heck know how my programs need fixing? > Any negative reactions to smart pointers on my side may be fueled by a disturbing amount of cargo culting that I had to witness since their inclusion in the standard. Any positive reactions to smart pointers on my side may be fuelled by over 30 years experience in using them.
- josefx 6y ago> How do you heck know how my programs need fixing? You where the one complaining that sample one liners with void return types where bad code. In my experience shared_ptr is overkill in nearly all trivial code examples, so any one liner containing one is bad code. > Any positive reactions to smart pointers on my side may be fuelled by over 30 years experience in using them. Hope you never had to deal with code reviews that suggested putting scoped std::vector uses in shared_ptr s to avoid stack overflows. Or really any code that put objects into smart pointers because it could not because it should.
- zabzonk 6y agoI have never, ever used, or suggested the use of shared_ptr, which I believe is not a construct that should be in C++ or any other language.
- rualca 6y ago> (...) shared_ptr, which I believe is not a construct that should be in C++ or any other language. What's your rationale for that assertion?