added implementation and tests of flat_map()

This commit is contained in:
Andrzej Krzemienski
2018-06-28 23:27:42 +02:00
parent 701afd43a4
commit 71d797b9ee
4 changed files with 340 additions and 1 deletions

View File

@ -170,6 +170,15 @@ public:
return none;
}
template <typename F>
optional<typename optional_detail::optional_value_type<typename boost::result_of<F(T&)>::type>::type> flat_map(F f) const
{
if (this->has_value())
return f(get());
else
return none;
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
optional(T&& /* rhs */) BOOST_NOEXCEPT { detail::prevent_binding_rvalue<T&&>(); }