diff --git a/source/coral.cpp b/source/coral.cpp index ad03759..ace6e29 100644 --- a/source/coral.cpp +++ b/source/coral.cpp @@ -382,6 +382,13 @@ export namespace coral { } } + /** + * Invokes the `apply` procedure if the optional is not empty, otherwise having no side-effects. + */ + void and_then(closure const & apply) { + if (this->has_value()) apply(**this); + } + /** * Returns `true` if the optional contains a value, otherwise `false`. */