3 ms·
How do you get memory without new nowadays?
by andi999 5y ago
How do you get memory without new nowadays?
- chlorion 5y agoAs well as smart pointers as others have mentioned, standard library containers (other than smart pointers) are another way to handle dynamic allocations in certain situations. The vector container is probably the best example here, it alone provides massive safety and usability benefits over using new or malloc directly!
- kaetemi 5y agomake_unique, etc.
- usefulcat 5y agoThey’re probably referring to preferring std::make_unique or std::make_shared to bare new/delete. Using either of the former makes the ownership semantics clear and avoids the need to remember to call delete at the appropriate time.