Skip to content

[optional] Use x.has_value() instead of bool(x) #4901

Closed
@jwakely

Description

@jwakely
Member

During last week's LWG telecon there was a strong preference expressed for using has_value() or prose "contains a value" instead of bool(*this).

Should we do the same for std::optional?

Activity

jensmaurer

jensmaurer commented on Sep 13, 2021

@jensmaurer
Member

At least for those parts where we talk about the boolean conversions, yes. I'm not sure adjusting "*this contains a value" yields a net benefit.

self-assigned this
on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @jwakely@jensmaurer

    Issue actions

      [optional] Use x.has_value() instead of bool(x) · Issue #4901 · cplusplus/draft