Exception safety guarantees
Explore the concept of exception safety guarantees within std::variant in C++17. Understand how exceptions can affect the variant's state during assignment and emplacement, what a valueless-by-exception variant means, and the implications for accessing variant values after exceptions. This lesson helps you safely manage and use std::variant in your C++ programs.
We'll cover the following...
We'll cover the following...
So far everything looks nice and smooth… but what happens when there’s an exception during the creation of the alternative in a variant?
Example:
In the first case - with the assignment operator - the ...