We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
C++ Object Lifetime: From Start to Finish - Thamara Andrade - CppCon 2023
"C++ Object Lifetime: From Start to Finish - Explained and demonstrated through examples"
- RAII (Resource Acquisition Is Initialization) is a technique to manage resources and ensure their lifetime is tied to the object’s lifetime.
- The lifetime of an object starts when the storage is obtained and the constructor has finalized it.
- The standard library uses RAII to encapsulate resources, making it easier to manage them.
-
The
constkeyword can affect the lifetime of an object, as it can prevent the object from being modified. - Lifetime extension occurs when a reference to an object is created, extending the object’s lifetime.
-
The
std::vectorclass has a non-vex initialization, meaning it has a constructor that is not trivial. -
The
std::unique_ptrclass is an example of RAII in action, encapsulating a pointer and managing its lifetime. -
The
std::lock_guardclass is another example of RAII, managing the lifetime of a lock. -
The
std::thread_localkeyword is used to declare variables that are local to a thread. -
The
std::dynamic_keykeyword is used to declare variables that are allocated at runtime. -
The
std::static_keykeyword is used to declare variables that are allocated at compile-time. -
The
std::automatic_keykeyword is used to declare variables that are allocated at runtime. -
The
std::const_keykeyword is used to declare variables that are constant. -
The
std::non_const_keykeyword is used to declare variables that are not constant. -
The
std::const_refkeyword is used to declare a reference to a constant object. -
The
std::non_const_refkeyword is used to declare a reference to a non-constant object. -
The
std::movekeyword is used to transfer ownership of an object. -
The
std::forwardkeyword is used to forward an object to another function. -
The
std::bindkeyword is used to bind a function to an object. -
The
std::functionkeyword is used to declare a function object. -
The
std::threadkeyword is used to declare a thread. -
The
std::mutexkeyword is used to declare a mutex. -
The
std::lockkeyword is used to lock a mutex. -
The
std::unlockkeyword is used to unlock a mutex. -
The
std::try_lockkeyword is used to try to lock a mutex. -
The
std::try_unlockkeyword is used to try to unlock a mutex. -
The
std::unique_lockkeyword is used to declare a unique lock. -
The
std::shared_lockkeyword is used to declare a shared lock. -
The
std::shared_ptrkeyword is used to declare a shared pointer. -
The
std::unique_ptrkeyword is used to declare a unique pointer. -
The
std::weak_ptrkeyword is used to declare a weak pointer. -
The
std::atomickeyword is used to declare an atomic variable. -
The
std::atomic_refkeyword is used to declare a reference to an atomic variable. -
The
std::atomic_ptrkeyword is used to declare a pointer to an atomic variable. -
The
std::atomic_shared_ptrkeyword is used to declare a shared pointer to an atomic variable. -
The
std::atomic_unique_ptrkeyword is used to declare a unique pointer to an atomic variable. -
The
std::atomic_weak_ptrkeyword is used to declare a weak pointer to an atomic variable. -
The
std::atomic_lockkeyword is used to lock an atomic variable. -
The
std::atomic_unlockkeyword is used to unlock an atomic variable. -
The
std::atomic_try_lockkeyword is used to try to lock an atomic variable. -
The
std::atomic_try_unlockkeyword is used to try to unlock an atomic variable. -
The
std::atomic_exchangekeyword is used to exchange the value of an atomic variable. -
The
std::atomic_exchange_ptrkeyword is used to exchange the value of a pointer to an atomic variable. -
The
std::atomic_loadkeyword is used to load the value of an atomic variable. -
The
std::atomic_load_ptrkeyword is used to load the value of a pointer to an atomic variable. -
The
std::atomic_storekeyword is used to store the value of an atomic variable. -
The
std::atomic_store_ptrkeyword is used to store the value of a pointer to an atomic variable. -
The
std::atomic_compare_exchangekeyword is used to compare and exchange the value of an atomic variable. -
The
std::atomic_compare_exchange_ptrkeyword is used to compare and exchange the value of a pointer to an atomic variable. -
The
std::atomic_fetch_addkeyword is used to fetch and add the value of an atomic variable. -
The
std::atomic_fetch_subkeyword is used to fetch and subtract the value of an atomic variable. -
The
std::atomic_fetch_andkeyword is used to fetch and bitwise AND the value of an atomic variable. -
The
std::atomic_fetch_orkeyword is used to fetch and bitwise OR the value of an atomic variable. -
The
std::atomic_fetch_xorkeyword is used to fetch and bitwise XOR the value of an atomic variable. -
The
std::atomic_fetch_nandkeyword is used to fetch and bitwise NAND the value of an atomic variable. -
The
std::atomic_fetch_andnotkeyword is used to fetch and bitwise ANDNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotkeyword is used to fetch and bitwise ORNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotkeyword is used to fetch and bitwise XORNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotkeyword is used to fetch and bitwise NANDNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotkeyword is used to fetch and bitwise ANDNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotkeyword is used to fetch and bitwise ORNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotkeyword is used to fetch and bitwise XORNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotkeyword is used to fetch and bitwise NANDNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnotnotnotkeyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnotnotnotkeyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnotnotnotkeyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnotnotnotkeyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOT