A Basic Example Of std::optional
Let's look at std::optional in action.
We'll cover the following...
Here’s a simple example of what you can do with optional:
Press + to interact
// UI Class...std::optional<std::string> UI::FindUserNick(){if (IsNickAvailable())return mStrNickName; // return a stringreturn std::nullopt; // same as return { };}// use:std::optional<std::string> UserNick = UI->FindUserNick();if (UserNick)Show(*UserNick);
In the above code, we define a function that returns an ...