fork download
  1. #include <iostream>
  2. #include <optional>
  3.  
  4. void fn(const std::optional<std::string> s)
  5. {
  6. if (s)
  7. std::cout << *s << '\n';
  8. else
  9. std::cout << "Empty" << '\n';
  10. }
  11.  
  12. int main()
  13. {
  14. fn("Hello");
  15. fn("Goodbye");
  16. fn(std::optional<std::string>());
  17. }
  18.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty