Reimplement coral::optional::and_then

This commit is contained in:
kayomn 2023-02-27 00:46:12 +00:00
parent 26182be695
commit f43314cb53

View File

@ -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<void(element &)> const & apply) {
if (this->has_value()) apply(**this);
}
/**
* Returns `true` if the optional contains a value, otherwise `false`.
*/