Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 27s8 days 9 hours 54 minutes 27 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 27s8 days 9 hours 54 minutes 27 seconds.

Sign in to watch this lesson
Ownership Types, Views and Type Erasure · 3:48
Why the standard library would rather call new for you. make_unique and make_shared name the type once, make sure the object is owned before anything can throw (we force a bad_alloc to watch emplace_back(new W) leak), and make_shared fuses the object and its control block into one allocation, which we measure on a Mac. The cost: that fused block stays allocated until the last weak_ptr is gone, and the make functions can't take custom deleters or braces.