diff options
-rw-r--r-- | libstdc++-v3/include/std/optional | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index af72004..9ed7ab5 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -760,7 +760,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(is_nothrow_constructible_v<_Tp, const _Up&>) { if (__t) - emplace(*__t); + emplace(__t._M_get()); } template<typename _Up, @@ -773,7 +773,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(is_nothrow_constructible_v<_Tp, const _Up&>) { if (__t) - emplace(*__t); + emplace(__t._M_get()); } template<typename _Up, @@ -786,7 +786,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(is_nothrow_constructible_v<_Tp, _Up>) { if (__t) - emplace(std::move(*__t)); + emplace(std::move(__t._M_get())); } template<typename _Up, @@ -799,7 +799,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION noexcept(is_nothrow_constructible_v<_Tp, _Up>) { if (__t) - emplace(std::move(*__t)); + emplace(std::move(__t._M_get())); } template<typename... _Args, @@ -863,9 +863,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__u) { if (this->_M_is_engaged()) - this->_M_get() = *__u; + this->_M_get() = __u._M_get(); else - this->_M_construct(*__u); + this->_M_construct(__u._M_get()); } else { @@ -889,9 +889,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__u) { if (this->_M_is_engaged()) - this->_M_get() = std::move(*__u); + this->_M_get() = std::move(__u._M_get()); else - this->_M_construct(std::move(*__u)); + this->_M_construct(std::move(__u._M_get())); } else { @@ -1056,7 +1056,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast<_Tp>(std::forward<_Up>(__u)); } -#if __cpp_lib_optional >= 202110L +#if __cpp_lib_optional >= 202110L // C++23 // [optional.monadic] template<typename _Fn> @@ -1068,7 +1068,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "the function passed to std::optional<T>::and_then " "must return a std::optional"); if (has_value()) - return std::__invoke(std::forward<_Fn>(__f), **this); + return std::__invoke(std::forward<_Fn>(__f), _M_get()); else return _Up(); } @@ -1082,7 +1082,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "the function passed to std::optional<T>::and_then " "must return a std::optional"); if (has_value()) - return std::__invoke(std::forward<_Fn>(__f), **this); + return std::__invoke(std::forward<_Fn>(__f), _M_get()); else return _Up(); } @@ -1096,7 +1096,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "the function passed to std::optional<T>::and_then " "must return a std::optional"); if (has_value()) - return std::__invoke(std::forward<_Fn>(__f), std::move(**this)); + return std::__invoke(std::forward<_Fn>(__f), std::move(_M_get())); else return _Up(); } @@ -1110,7 +1110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "the function passed to std::optional<T>::and_then " "must return a std::optional"); if (has_value()) - return std::__invoke(std::forward<_Fn>(__f), std::move(**this)); + return std::__invoke(std::forward<_Fn>(__f), std::move(_M_get())); else return _Up(); } @@ -1121,7 +1121,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using _Up = remove_cv_t<invoke_result_t<_Fn, _Tp&>>; if (has_value()) - return optional<_Up>(_Optional_func<_Fn>{__f}, **this); + return optional<_Up>(_Optional_func<_Fn>{__f}, _M_get()); else return optional<_Up>(); } @@ -1132,7 +1132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using _Up = remove_cv_t<invoke_result_t<_Fn, const _Tp&>>; if (has_value()) - return optional<_Up>(_Optional_func<_Fn>{__f}, **this); + return optional<_Up>(_Optional_func<_Fn>{__f}, _M_get()); else return optional<_Up>(); } @@ -1143,7 +1143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using _Up = remove_cv_t<invoke_result_t<_Fn, _Tp>>; if (has_value()) - return optional<_Up>(_Optional_func<_Fn>{__f}, std::move(**this)); + return optional<_Up>(_Optional_func<_Fn>{__f}, std::move(_M_get())); else return optional<_Up>(); } @@ -1154,7 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using _Up = remove_cv_t<invoke_result_t<_Fn, const _Tp>>; if (has_value()) - return optional<_Up>(_Optional_func<_Fn>{__f}, std::move(**this)); + return optional<_Up>(_Optional_func<_Fn>{__f}, std::move(_M_get())); else return optional<_Up>(); } @@ -1193,9 +1193,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX20_CONSTEXPR void reset() noexcept { this->_M_reset(); } private: -#if __cplusplus >= 202002L + using _Base::_M_get; + template<typename _Up> friend class optional; +#if __cpp_lib_optional >= 202110L // C++23 template<typename _Fn, typename _Value> explicit constexpr optional(_Optional_func<_Fn> __f, _Value&& __v) |