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