Default Construction
Explore how to efficiently create default-constructed objects inside std::optional using std::in_place in C++17. Understand constructor and destructor behavior to avoid unnecessary copies or moves, and learn approaches for handling non-copyable or non-movable types like std::mutex with std::optional.
We'll cover the following...
We'll cover the following...
Movable Types
If you have a class with a default constructor, like:
How would you create an optional that contains UserName{}?
You can write:
That works but it creates an additional temporary object. If we traced each different constructor and ...