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
const
keyword 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::vector
class has a non-vex initialization, meaning it has a constructor that is not trivial. -
The
std::unique_ptr
class is an example of RAII in action, encapsulating a pointer and managing its lifetime. -
The
std::lock_guard
class is another example of RAII, managing the lifetime of a lock. -
The
std::thread_local
keyword is used to declare variables that are local to a thread. -
The
std::dynamic_key
keyword is used to declare variables that are allocated at runtime. -
The
std::static_key
keyword is used to declare variables that are allocated at compile-time. -
The
std::automatic_key
keyword is used to declare variables that are allocated at runtime. -
The
std::const_key
keyword is used to declare variables that are constant. -
The
std::non_const_key
keyword is used to declare variables that are not constant. -
The
std::const_ref
keyword is used to declare a reference to a constant object. -
The
std::non_const_ref
keyword is used to declare a reference to a non-constant object. -
The
std::move
keyword is used to transfer ownership of an object. -
The
std::forward
keyword is used to forward an object to another function. -
The
std::bind
keyword is used to bind a function to an object. -
The
std::function
keyword is used to declare a function object. -
The
std::thread
keyword is used to declare a thread. -
The
std::mutex
keyword is used to declare a mutex. -
The
std::lock
keyword is used to lock a mutex. -
The
std::unlock
keyword is used to unlock a mutex. -
The
std::try_lock
keyword is used to try to lock a mutex. -
The
std::try_unlock
keyword is used to try to unlock a mutex. -
The
std::unique_lock
keyword is used to declare a unique lock. -
The
std::shared_lock
keyword is used to declare a shared lock. -
The
std::shared_ptr
keyword is used to declare a shared pointer. -
The
std::unique_ptr
keyword is used to declare a unique pointer. -
The
std::weak_ptr
keyword is used to declare a weak pointer. -
The
std::atomic
keyword is used to declare an atomic variable. -
The
std::atomic_ref
keyword is used to declare a reference to an atomic variable. -
The
std::atomic_ptr
keyword is used to declare a pointer to an atomic variable. -
The
std::atomic_shared_ptr
keyword is used to declare a shared pointer to an atomic variable. -
The
std::atomic_unique_ptr
keyword is used to declare a unique pointer to an atomic variable. -
The
std::atomic_weak_ptr
keyword is used to declare a weak pointer to an atomic variable. -
The
std::atomic_lock
keyword is used to lock an atomic variable. -
The
std::atomic_unlock
keyword is used to unlock an atomic variable. -
The
std::atomic_try_lock
keyword is used to try to lock an atomic variable. -
The
std::atomic_try_unlock
keyword is used to try to unlock an atomic variable. -
The
std::atomic_exchange
keyword is used to exchange the value of an atomic variable. -
The
std::atomic_exchange_ptr
keyword is used to exchange the value of a pointer to an atomic variable. -
The
std::atomic_load
keyword is used to load the value of an atomic variable. -
The
std::atomic_load_ptr
keyword is used to load the value of a pointer to an atomic variable. -
The
std::atomic_store
keyword is used to store the value of an atomic variable. -
The
std::atomic_store_ptr
keyword is used to store the value of a pointer to an atomic variable. -
The
std::atomic_compare_exchange
keyword is used to compare and exchange the value of an atomic variable. -
The
std::atomic_compare_exchange_ptr
keyword is used to compare and exchange the value of a pointer to an atomic variable. -
The
std::atomic_fetch_add
keyword is used to fetch and add the value of an atomic variable. -
The
std::atomic_fetch_sub
keyword is used to fetch and subtract the value of an atomic variable. -
The
std::atomic_fetch_and
keyword is used to fetch and bitwise AND the value of an atomic variable. -
The
std::atomic_fetch_or
keyword is used to fetch and bitwise OR the value of an atomic variable. -
The
std::atomic_fetch_xor
keyword is used to fetch and bitwise XOR the value of an atomic variable. -
The
std::atomic_fetch_nand
keyword is used to fetch and bitwise NAND the value of an atomic variable. -
The
std::atomic_fetch_andnot
keyword is used to fetch and bitwise ANDNOT the value of an atomic variable. -
The
std::atomic_fetch_ornot
keyword is used to fetch and bitwise ORNOT the value of an atomic variable. -
The
std::atomic_fetch_xornot
keyword is used to fetch and bitwise XORNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnot
keyword is used to fetch and bitwise NANDNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnot
keyword is used to fetch and bitwise ANDNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnot
keyword is used to fetch and bitwise ORNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnot
keyword is used to fetch and bitwise XORNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnot
keyword is used to fetch and bitwise NANDNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_ornotnotnotnotnotnotnotnot
keyword is used to fetch and bitwise ORNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_xornotnotnotnotnotnotnotnot
keyword is used to fetch and bitwise XORNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_nandnotnotnotnotnotnotnotnot
keyword is used to fetch and bitwise NANDNOTNOTNOTNOTNOTNOTNOTNOT the value of an atomic variable. -
The
std::atomic_fetch_andnotnotnotnotnotnotnotnotnot
keyword is used to fetch and bitwise ANDNOTNOTNOTNOTNOT