| ... | @@ -828,6 +828,10 @@ private: | ... | @@ -828,6 +828,10 @@ private: |
| 828 | template <class _Up> | 828 | template <class _Up> |
| 829 | constexpr static bool __libcpp_opt_ref_ctor_deleted = | 829 | constexpr static bool __libcpp_opt_ref_ctor_deleted = |
| 830 | is_lvalue_reference_v<_Tp> && reference_constructs_from_temporary_v<_Tp, _Up>; | 830 | is_lvalue_reference_v<_Tp> && reference_constructs_from_temporary_v<_Tp, _Up>; |
| | 831 | |
| | 832 | template <class _Up> |
| | 833 | constexpr static bool __ref_ctor_enabled = |
| | 834 | is_lvalue_reference_v<_Tp> && !reference_constructs_from_temporary_v<_Tp, _Up>; |
| 831 | # endif | 835 | # endif |
| 832 | | 836 | |
| 833 | // LWG2756: conditionally explicit conversion from _Up | 837 | // LWG2756: conditionally explicit conversion from _Up |
| ... | @@ -935,7 +939,7 @@ public: | ... | @@ -935,7 +939,7 @@ public: |
| 935 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> | 939 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> |
| 936 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) | 940 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) |
| 937 | # if _LIBCPP_STD_VER >= 26 | 941 | # if _LIBCPP_STD_VER >= 26 |
| 938 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>) | 942 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>) |
| 939 | # endif | 943 | # endif |
| 940 | { | 944 | { |
| 941 | this->__construct_from(__v); | 945 | this->__construct_from(__v); |
| ... | @@ -943,7 +947,7 @@ public: | ... | @@ -943,7 +947,7 @@ public: |
| 943 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> | 947 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> |
| 944 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) | 948 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) |
| 945 | # if _LIBCPP_STD_VER >= 26 | 949 | # if _LIBCPP_STD_VER >= 26 |
| 946 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up&>) | 950 | noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>) |
| 947 | # endif | 951 | # endif |
| 948 | { | 952 | { |
| 949 | this->__construct_from(__v); | 953 | this->__construct_from(__v); |
| ... | @@ -981,25 +985,25 @@ public: | ... | @@ -981,25 +985,25 @@ public: |
| 981 | | 985 | |
| 982 | // optional(optional<U>& rhs) | 986 | // optional(optional<U>& rhs) |
| 983 | template <class _Up> | 987 | template <class _Up> |
| 984 | requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | 988 | requires __ref_ctor_enabled<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && (!is_same_v<_Tp&, _Up>) && |
| 985 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&> | 989 | is_constructible_v<_Tp&, _Up&> |
| 986 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up&, _Tp&>) | 990 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up&, _Tp&>) |
| 987 | optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) { | 991 | optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) { |
| 988 | this->__construct_from(__rhs); | 992 | this->__construct_from(__rhs); |
| 989 | } | 993 | } |
| 990 | | 994 | |
| 991 | template <class _Up> | 995 | template <class _Up> |
| 992 | requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | 996 | requires __libcpp_opt_ref_ctor_deleted<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && |
| 993 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&> | 997 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&> |
| 994 | constexpr explicit optional(optional<_Up>& __rhs) noexcept = delete; | 998 | constexpr explicit optional(optional<_Up>& __rhs) noexcept = delete; |
| 995 | | 999 | |
| 996 | // optional(const optional<U>&) | 1000 | // optional(const optional<U>&) |
| 997 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> | 1001 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0> |
| 998 | requires __libcpp_opt_ref_ctor_deleted<_Up> | 1002 | requires __libcpp_opt_ref_ctor_deleted<const _Up&> |
| 999 | optional(const optional<_Up>&) = delete; | 1003 | optional(const optional<_Up>&) = delete; |
| 1000 | | 1004 | |
| 1001 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> | 1005 | template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0> |
| 1002 | requires __libcpp_opt_ref_ctor_deleted<_Up> | 1006 | requires __libcpp_opt_ref_ctor_deleted<const _Up&> |
| 1003 | explicit optional(const optional<_Up>&) = delete; | 1007 | explicit optional(const optional<_Up>&) = delete; |
| 1004 | | 1008 | |
| 1005 | // optional(optional<U>&&) | 1009 | // optional(optional<U>&&) |
| ... | @@ -1013,16 +1017,16 @@ public: | ... | @@ -1013,16 +1017,16 @@ public: |
| 1013 | | 1017 | |
| 1014 | // optional(const optional<U>&&) | 1018 | // optional(const optional<U>&&) |
| 1015 | template <class _Up> | 1019 | template <class _Up> |
| 1016 | requires(!__libcpp_opt_ref_ctor_deleted<_Up>) && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | 1020 | requires __ref_ctor_enabled<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && |
| 1017 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up> | 1021 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up> |
| 1018 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!is_convertible_v<const _Up, _Tp&>) | 1022 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!is_convertible_v<const _Up, _Tp&>) |
| 1019 | optional(const optional<_Up>&& __v) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) { | 1023 | optional(const optional<_Up>&& __v) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) { |
| 1020 | this->__construct_from(std::move(__v)); | 1024 | this->__construct_from(std::move(__v)); |
| 1021 | } | 1025 | } |
| 1022 | | 1026 | |
| 1023 | template <class _Up> | 1027 | template <class _Up> |
| 1024 | requires __libcpp_opt_ref_ctor_deleted<_Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && | 1028 | requires __libcpp_opt_ref_ctor_deleted<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && |
| 1025 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up> | 1029 | (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up> |
| 1026 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>&& __v) noexcept = delete; | 1030 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>&& __v) noexcept = delete; |
| 1027 | # endif | 1031 | # endif |
| 1028 | | 1032 | |