vittorioromeo / scelta

(experimental) Syntactic sugar for variant and optional types.
https://vittorioromeo.info
MIT License
157 stars 10 forks source link

Add support for TartanLlama's `tl::optional` #7

Closed vittorioromeo closed 6 years ago

vittorioromeo commented 6 years ago

This PR adds support for tl::optional to scelta. This excellent optional implementation provides useful continuations. E.g.

tl::optional<image> get_cute_cat (const image& img) {
    return crop_to_cat(img)
           .and_then(add_bow_tie)
           .and_then(make_eyes_sparkle)
           .map(make_smaller)
           .map(add_rainbow);
}

tl::optional support is enabled if __has_include(<tl/optional.hpp>). When enabled, the SCELTA_SUPPORT_OPTIONAL_TL is defined.

Automatic detection of tl::optional can be disabled by defining SCELTA_SUPPORT_OPTIONAL_TL_DISABLE.