Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please compare to C++17's declaration-in-if in the readme #63

Open
stevecotton opened this issue Jun 6, 2024 · 0 comments
Open

Please compare to C++17's declaration-in-if in the readme #63

stevecotton opened this issue Jun 6, 2024 · 0 comments

Comments

@stevecotton
Copy link

For the readme's "For example, instead of writing this code:", the example could also be written using C++17's declaration-in-if syntax:

std::optional<image> get_cute_cat (const image& img) {
    if (auto cropped = crop_to_cat(img)) {
        if (auto with_tie = add_bow_tie(*cropped)) {
            if (auto with_sparkles = make_eyes_sparkle(*with_tie)) {
                return add_rainbow(make_smaller(*with_sparkles));
            }
        }
    }

    return std::nullopt;
}

I'm looking at the library because it's been mentioned on a Debian mailing list, but AFAICS the syntax built into C++17 already provides these benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant