optional icon indicating copy to clipboard operation
optional copied to clipboard

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

Open stevecotton opened this issue 1 year ago • 0 comments

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.

stevecotton avatar Jun 06 '24 17:06 stevecotton