diff --git a/include/boost/optional/detail/optional_reference_spec.hpp b/include/boost/optional/detail/optional_reference_spec.hpp index 4940a46..9cb2b5c 100644 --- a/include/boost/optional/detail/optional_reference_spec.hpp +++ b/include/boost/optional/detail/optional_reference_spec.hpp @@ -168,7 +168,8 @@ public: bool has_value() const BOOST_NOEXCEPT { return ptr_ != 0; } template - auto map(F f) const -> optional + optional::type> + map(F f) const { if (this->has_value()) return f(this->get()); @@ -177,8 +178,8 @@ public: } template - auto flat_map(F f) const -> - optional::type> + optional::type> + flat_map(F f) const { if (this->has_value()) return f(get()); diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 979ebcc..6be4535 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -76,6 +76,23 @@ struct optional_value_type< ::boost::optional > template T declval(); + +// implementing my own result_of so that it works for C++11 (std::result_of) +// and in C++20 (std::invoke_result). +template ()(declval()))> +struct result_of +{ + typedef Rslt type; +}; + +template ::type>::type> +struct result_value_type +{ + typedef Rslt type; +}; + +// optional()(optional_detail::declval()))>::type> + }} // namespace boost::optional_detail namespace boost { @@ -1396,7 +1413,7 @@ class optional } template - optional()(optional_detail::declval()))> map(F f) & + optional::type> map(F f) & { if (this->has_value()) return f(get()); @@ -1405,7 +1422,7 @@ class optional } template - optional()(optional_detail::declval()))> map(F f) const& + optional::type> map(F f) const& { if (this->has_value()) return f(get()); @@ -1414,7 +1431,7 @@ class optional } template - optional()(optional_detail::declval()))> map(F f) && + optional::type> map(F f) && { if (this->has_value()) return f(boost::move(this->get())); @@ -1423,7 +1440,8 @@ class optional } template - optional()(optional_detail::declval()))>::type> flat_map(F f) & + optional::type> + flat_map(F f) & { if (this->has_value()) return f(get()); @@ -1432,7 +1450,8 @@ class optional } template - optional()(optional_detail::declval()))>::type>flat_map(F f) const& + optional::type> + flat_map(F f) const& { if (this->has_value()) return f(get()); @@ -1441,7 +1460,8 @@ class optional } template - optional()(optional_detail::declval()))>::type>flat_map(F f) && + optional::type> + flat_map(F f) && { if (this->has_value()) return f(boost::move(get())); @@ -1460,7 +1480,8 @@ class optional } template - optional()(optional_detail::declval()))> map(F f) + optional::type> + map(F f) { if (this->has_value()) return f(get()); @@ -1469,7 +1490,8 @@ class optional } template - optional()(optional_detail::declval()))> map(F f) const + optional::type> + map(F f) const { if (this->has_value()) return f(get()); @@ -1478,7 +1500,8 @@ class optional } template - optional()(optional_detail::declval()))>::type> flat_map(F f) + optional::type> + flat_map(F f) { if (this->has_value()) return f(get()); @@ -1487,7 +1510,8 @@ class optional } template - optional()(optional_detail::declval()))>::type> flat_map(F f) const + optional::type> + flat_map(F f) const { if (this->has_value()) return f(get());