weak_ptr, make_shared and memory deallocation

Is my understanding correct? Yes. If your weak_ptrs significantly outlive the (large) object and you are tight on memory, it may be beneficial to avoid make_shared. However, “large” here is measured by sizeof, and many conceptually “large” objects (for example, most standard containers, except std::array) are quite small by that metric, because they allocate additional … Read more

Is make_shared really more efficient than new?

As infrastructure I was using llvm/clang 3.0 along with the llvm std c++ library within XCode4. Well that appears to be your problem. The C++11 standard states the following requirements for make_shared<T> (and allocate_shared<T>), in section 20.7.2.2.6: Requires: The expression ::new (pv) T(std::forward(args)…), where pv has type void* and points to storage suitable to hold … Read more