logoalt Hacker News

boulosyesterday at 7:09 PM1 replyview on HN

They linked directly to https://alexgaynor.net/2019/apr/21/modern-c++-wont-save-us/ which did exactly what I'd guessed as its example:

> The following code for example, simply returns an uninitialized value:

  #include <optional>

  int f() {
    std::optional<int> x(std::nullopt);
    return *x;
  }

Replies

on_the_trainyesterday at 7:26 PM

But that is not idiomatic at all. Idiomatic would be too use .value()

show 3 replies