xtd 0.2.0
Loading...
Searching...
No Matches
format_optional.cpp

Show how to use format xtd::format class with std::optional.

#include <xtd/console>
#include <xtd/environment>
#include <xtd/format>
#include <xtd/null_opt>
#include <xtd/optional>
using namespace xtd;
auto main() -> int {
console::out << format("{}", optional<string> {"string value"}) << environment::new_line;
console::out << format("{}", optional<string> {"string value"}.value()) << environment::new_line;
console::out << format("{}", optional<string> {}.value_or("fallback string")) << environment::new_line;
console::out << format("{}", optional<string> {}) << environment::new_line;
console::out << format("{}", nullopt) << environment::new_line;
}
// This code produces the following output :
//
// (string value)
// string value
// fallback string
// (null)
// (null)
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:175
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10