/** * @author Ayoub Chouak (@ntauth) * @website http://chouak.me * @note This requires a C++17-compliant compiler (ex. MSVC14, Clang5) */ #include #include #include #include template std::ostream& operator<<(std::ostream& os, std::optional nullable) { if (nullable.has_value()) os << nullable.value(); return os; } int main(int argc, char** argv) { std::optional int_n; std::optional string_n; std::optional string_n_{ "I have a value!" }; std::cout << int_n << string_n << string_n_ << std::endl; std::cin.get(); }