diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-11-18 18:45:56 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-11-18 19:12:49 +0300 |
commit | fab560ba9f54a13bb6df30dd56b6db7467bddc04 (patch) | |
tree | 4a38b662f202b09993f932aa4570ca3f4b40fb21 /contrib/libs | |
parent | eb9ebcd66823f2331380c62c209c41382fcdabdb (diff) | |
download | ydb-fab560ba9f54a13bb6df30dd56b6db7467bddc04.tar.gz |
Intermediate changes
commit_hash:253ff6780bbe06b38b22d1a48de66095f832c01d
Diffstat (limited to 'contrib/libs')
3 files changed, 468 insertions, 96 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h index 3f468fc63b..3f25e00859 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h @@ -119,9 +119,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected() noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened requires is_default_constructible_v<_Tp> - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_)); - } + : __union_(std::in_place), __has_val_(true) {} _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete; @@ -136,14 +134,7 @@ public: noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> && !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>)) - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); - } else { - std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); - } - } - + : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) { } _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> @@ -154,13 +145,7 @@ public: noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>) requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> && !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)) - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); - } else { - std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); - } - } + : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) { } private: template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> @@ -200,26 +185,14 @@ public: expected(const expected<_Up, _OtherErr>& __other) noexcept(is_nothrow_constructible_v<_Tp, const _Up&> && is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); - } else { - std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); - } - } + : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>) expected(expected<_Up, _OtherErr>&& __other) noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); - } else { - std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); - } - } + : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) {} template <class _Up = _Tp> requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && @@ -227,61 +200,47 @@ public: (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u)); - } + : __union_(std::in_place, std::forward<_Up>(__u)), __has_val_(true) {} template <class _OtherErr> requires is_constructible_v<_Err, const _OtherErr&> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const unexpected<_OtherErr>& __unex) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __unex.error()); - } + : __union_(std::unexpect, __unex.error()), __has_val_(false) {} template <class _OtherErr> requires is_constructible_v<_Err, _OtherErr> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(unexpected<_OtherErr>&& __unex) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); - } + : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} template <class... _Args> requires is_constructible_v<_Tp, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); - } + : __union_(std::in_place, std::forward<_Args>(__args)...), __has_val_(true) {} template <class _Up, class... _Args> requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::in_place, __il, std::forward<_Args>(__args)...), __has_val_(true) {} template <class... _Args> requires is_constructible_v<_Err, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) - noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); - } + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened + : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} template <class _Up, class... _Args> requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} // [expected.object.dtor], destructor @@ -440,9 +399,10 @@ public: std::destroy_at(std::addressof(__union_.__val_)); } else { std::destroy_at(std::addressof(__union_.__unex_)); - __has_val_ = true; } - return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); + std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); + __has_val_ = true; + return __union_.__val_; } template <class _Up, class... _Args> @@ -452,9 +412,10 @@ public: std::destroy_at(std::addressof(__union_.__val_)); } else { std::destroy_at(std::addressof(__union_.__unex_)); - __has_val_ = true; } - return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); + std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); + __has_val_ = true; + return __union_.__val_; } @@ -893,11 +854,15 @@ public: } private: - struct __empty_t {}; - template <class _ValueType, class _ErrorType> union __union_t { - _LIBCPP_HIDE_FROM_ABI constexpr __union_t() {} + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) + : __val_(std::forward<_Args>(__args)...) {} + + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( @@ -909,6 +874,14 @@ private: std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) = default; @@ -927,10 +900,17 @@ private: template <class _ValueType, class _ErrorType> requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>) union __union_t<_ValueType, _ErrorType> { - _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) + : __val_(std::forward<_Args>(__args)...) {} + + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( std::__expected_construct_in_place_from_invoke_tag, _Func&& __f, _Args&&... __args) @@ -941,6 +921,14 @@ private: std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) = default; @@ -950,7 +938,6 @@ private: requires(!is_trivially_destructible_v<_ValueType> || !is_trivially_destructible_v<_ErrorType>) {} - _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_; _LIBCPP_NO_UNIQUE_ADDRESS _ValueType __val_; _LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_; }; @@ -998,11 +985,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs) noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>) - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); - } - } + : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>) @@ -1011,51 +994,35 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs) noexcept(is_nothrow_move_constructible_v<_Err>) requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>) - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); - } - } + : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const expected<_Up, _OtherErr>& __rhs) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); - } - } + : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(expected<_Up, _OtherErr>&& __rhs) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); - } - } + : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} template <class _OtherErr> requires is_constructible_v<_Err, const _OtherErr&> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const unexpected<_OtherErr>& __unex) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __unex.error()); - } + : __union_(std::unexpect, __unex.error()), __has_val_(false) {} template <class _OtherErr> requires is_constructible_v<_Err, _OtherErr> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(unexpected<_OtherErr>&& __unex) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); - } + : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {} @@ -1063,17 +1030,13 @@ public: requires is_constructible_v<_Err, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} template <class _Up, class... _Args> requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} private: template <class _Func> @@ -1507,11 +1470,23 @@ private: union __union_t { _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__empty_)); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ErrorType>) = default; @@ -1534,11 +1509,23 @@ private: _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__empty_)); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ErrorType>) = default; diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch new file mode 100644 index 0000000000..36245f22b7 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch @@ -0,0 +1,385 @@ +diff --git a/include/__expected/expected.h b/include/__expected/expected.h +index 045370a..bf16c8f 100644 +--- a/include/__expected/expected.h ++++ b/include/__expected/expected.h +@@ -119,9 +119,7 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected() + noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened + requires is_default_constructible_v<_Tp> +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_)); +- } ++ : __union_(std::in_place), __has_val_(true) {} + + _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete; + +@@ -136,14 +134,7 @@ public: + noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened + requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> && + !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>)) +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); +- } +- } +- ++ : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) { } + + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) + requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> +@@ -154,13 +145,7 @@ public: + noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>) + requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> && + !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)) +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); +- } +- } ++ : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) { } + + private: + template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> +@@ -200,26 +185,14 @@ public: + expected(const expected<_Up, _OtherErr>& __other) + noexcept(is_nothrow_constructible_v<_Tp, const _Up&> && + is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); +- } +- } ++ : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>) + expected(expected<_Up, _OtherErr>&& __other) + noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); +- } +- } ++ : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) {} + + template <class _Up = _Tp> + requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && +@@ -227,61 +200,47 @@ public: + (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) + expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u)); +- } ++ : __union_(std::in_place, std::forward<_Up>(__u)), __has_val_(true) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, const _OtherErr&> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const unexpected<_OtherErr>& __unex) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __unex.error()); +- } ++ : __union_(std::unexpect, __unex.error()), __has_val_(false) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, _OtherErr> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(unexpected<_OtherErr>&& __unex) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); +- } ++ : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} + + template <class... _Args> + requires is_constructible_v<_Tp, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); +- } ++ : __union_(std::in_place, std::forward<_Args>(__args)...), __has_val_(true) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit + expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::in_place, __il, std::forward<_Args>(__args)...), __has_val_(true) {} + + template <class... _Args> + requires is_constructible_v<_Err, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) +- noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); +- } ++ noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened ++ : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit + expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} + + // [expected.object.dtor], destructor + +@@ -440,9 +399,10 @@ public: + std::destroy_at(std::addressof(__union_.__val_)); + } else { + std::destroy_at(std::addressof(__union_.__unex_)); +- __has_val_ = true; + } +- return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); ++ std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); ++ __has_val_ = true; ++ return __union_.__val_; + } + + template <class _Up, class... _Args> +@@ -452,9 +412,10 @@ public: + std::destroy_at(std::addressof(__union_.__val_)); + } else { + std::destroy_at(std::addressof(__union_.__unex_)); +- __has_val_ = true; + } +- return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); ++ std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); ++ __has_val_ = true; ++ return __union_.__val_; + } + + +@@ -893,11 +854,15 @@ public: + } + + private: +- struct __empty_t {}; +- + template <class _ValueType, class _ErrorType> + union __union_t { +- _LIBCPP_HIDE_FROM_ABI constexpr __union_t() {} ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) ++ : __val_(std::forward<_Args>(__args)...) {} ++ ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} + + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( +@@ -909,6 +874,14 @@ private: + std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) + = default; +@@ -927,10 +900,17 @@ private: + template <class _ValueType, class _ErrorType> + requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>) + union __union_t<_ValueType, _ErrorType> { +- _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; + _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) ++ : __val_(std::forward<_Args>(__args)...) {} ++ ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + std::__expected_construct_in_place_from_invoke_tag, _Func&& __f, _Args&&... __args) +@@ -941,6 +921,14 @@ private: + std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) + = default; +@@ -950,7 +938,6 @@ private: + requires(!is_trivially_destructible_v<_ValueType> || !is_trivially_destructible_v<_ErrorType>) + {} + +- _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_; + _LIBCPP_NO_UNIQUE_ADDRESS _ValueType __val_; + _LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_; + }; +@@ -998,11 +985,7 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs) + noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened + requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>) +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); +- } +- } ++ : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} + + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) + requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>) +@@ -1011,51 +994,35 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs) + noexcept(is_nothrow_move_constructible_v<_Err>) + requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>) +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); +- } +- } ++ : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const expected<_Up, _OtherErr>& __rhs) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); +- } +- } ++ : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, _OtherErr>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(expected<_Up, _OtherErr>&& __rhs) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); +- } +- } ++ : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, const _OtherErr&> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const unexpected<_OtherErr>& __unex) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __unex.error()); +- } ++ : __union_(std::unexpect, __unex.error()), __has_val_(false) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, _OtherErr> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(unexpected<_OtherErr>&& __unex) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); +- } ++ : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} + + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {} + +@@ -1063,17 +1030,13 @@ public: + requires is_constructible_v<_Err, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} + + private: + template <class _Func> +@@ -1507,11 +1470,23 @@ private: + union __union_t { + _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__empty_)); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ErrorType>) + = default; +@@ -1534,11 +1509,23 @@ private: + _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; + _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__empty_)); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ErrorType>) + = default; diff --git a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch index 0e2e9e1220..b0626579ba 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch @@ -12,7 +12,7 @@ index 27f01d9..174f97f 100644 _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/include/__expected/expected.h b/include/__expected/expected.h -index 045370a..3f468fc 100644 +index bf16c8f..3f25e00 100644 --- a/include/__expected/expected.h +++ b/include/__expected/expected.h @@ -62,7 +62,7 @@ |