Reimplement coral::optional::and_then
This commit is contained in:
parent
26182be695
commit
f43314cb53
@ -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`.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user