unique_ptr
also supports move semantics for passing free-store allocated objects around scopes.shared_ptr
is similar, but copied rather than moved. the resources it owns are destroyed whennew
’ policyEven though smart pointers do resource management, they provide no read/write policy for the resources they hold. Their usage does not help with the sharing of resources, as data races and other issues can occur.
Pointers are used in the following scenarios:
shared_ptr
)unique_ptr
)std::thread
using a functorthread
s share an address space
join
waits for a thread to terminate
thread
’s variadic constructor, and <functional>
’s ref()
and cref()
utilities)const
)mutex
: “a mutual exclusion object”
.lock()
.unlock()
unique_lock
’s constructor
defer_lock
in unique_lock
’s constructor and then manually using variadic lock()
condition_variable
provides utilities for ‘events’ in which one thread can wait for another thread to endfuture
/promise
.get()
a future
to get the value from it, blocking if wait is necessary.set_value()
in a promise, it passes the value to the corresponding future that waits for itpackaged_task
is used to produce the needed future/promise pairs that a caller would use:
.get_future()
to construct futuresthe used threads still have to be joined tho
async()
straight up returns a future
that a caller can .get()
. No worrying about threads.std::chrono
numeric_limits
: numeric_limits<float>::min();
template<typename C> using Value_type = typename C::value_type;
<utility>
pair
tuple
<regex>
<cmath>
<numeric>
<complex>
<random>
(that uses an engine and a distribution)<limits>