c++ - Are new and delete still useful in C++14? -


given availability of make_unique , make_shared, automatic deletion unique_ptr , shared_ptr destructors, situations (apart supporting legacy code) using new , delete in c++14?

while smart pointers preferable raw pointers in many cases, there still lots of use-cases new/delete in c++14.

if need write requires in-place construction, example:

  • a memory pool
  • an allocator
  • a tagged variant
  • binary messages buffer

you need use placement new and, possibly, delete. no way around that.

for containers want write, may want use raw pointers storage.

even standard smart pointers, still need new if want use custom deleters since make_unique , make_shared don't allow that.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -