All challenges
Multiple ChoiceIntermediate 45s

expected has_value check

In std::expected<int, std::error_code>, how do you check whether a value or error is held?
Options
  1. 1e.ok(), the dedicated member testing for a held value
  2. 2e.is_error() only, since has_value() is not provided
  3. 3You cannot check at all, it throws on the wrong side
  4. 4e.has_value() or the boolean conversion operator

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