All challenges
Multiple ChoiceBeginner 45s

std::optional value semantics on engagement

Which expression safely checks whether a std::optional<int> o holds a value?
Options
  1. 1if (o.has_value())
  2. 2if (o == nullptr)
  3. 3if (o.value_or(0))
  4. 4if (o.data() != nullptr)

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle