Skip to content

std::optional usage example with new if is iffy #23

@willwray

Description

@willwray
// nicer with new if syntax:
if (optional ofoo = parseFoo(str); ofoo)
   use(*ofoo);

Even nicer, old style, without the extraneous ofoo conditional?

if (optional ofoo = parseFoo(str))
   use(*ofoo);

Old style if could always be a single declaration,
new style needed for more complex cases.

We could argue the ifs and buts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions