From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 67BF3385841B; Fri, 11 Feb 2022 20:40:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67BF3385841B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9561] libstdc++: Back out some changes from P2325R3 backport [PR103904] X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: c56c398c39f6195c3d158f02514c33b7da73ebc2 X-Git-Newrev: 3273e704d04a98bcfccdc93c8d07e88f2b032043 Message-Id: <20220211204031.67BF3385841B@sourceware.org> Date: Fri, 11 Feb 2022 20:40:31 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2022 20:40:31 -0000 https://gcc.gnu.org/g:3273e704d04a98bcfccdc93c8d07e88f2b032043 commit r11-9561-g3273e704d04a98bcfccdc93c8d07e88f2b032043 Author: Patrick Palka Date: Fri Feb 11 15:39:06 2022 -0500 libstdc++: Back out some changes from P2325R3 backport [PR103904] In the P2325R3 backport r11-9555 the relaxation of the constraints on the partial specialization of __box (which is semantically equivalent to the primary template, only more space efficient) means some specializations of __box will now use the partial specialization instead of the primary template, which constitutes an ABI change unsuitable for a release branch. So this patch reverts this constraint change, which isn't needed for correctness anyway. Similarly, the change to use __non_propagating_cache for the data member split_view::_M_current (so that it's always default-initializable) also constitutes an unsuitable ABI change. This patch reverts this change too, and instead further constrains split_view's default constructor to require that we can default-initialize _M_current. PR libstdc++/103904 libstdc++-v3/ChangeLog: * include/std/ranges (__detail::__box): Revert r11-9555 changes to the constraints on the partial specialization and the now-unnecessary special member functions. (__detail::__non_propagating_cache::operator=): Remove now-unused overload added by r11-9555. (split_view::_OuterIter::__current): Adjust after reverting the r11-9555 change to the type of _M_current. (split_view::_M_current): Revert r11-9555 change to its type. (split_view::split_view): Constrain the default constructor further. * testsuite/std/ranges/adaptors/detail/copyable_box.cc: Disable now-irrelevant test for the r11-9555 changes to the partial specialization of __box. Diff: --- libstdc++-v3/include/std/ranges | 55 +++------------------- .../std/ranges/adaptors/detail/copyable_box.cc | 4 ++ 2 files changed, 11 insertions(+), 48 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 03c6275801f..4a65a49ed30 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -144,8 +144,7 @@ namespace ranges // std::optional. It provides just the subset of the primary template's // API that we currently use. template<__boxable _Tp> - requires copyable<_Tp> || (is_nothrow_move_constructible_v<_Tp> - && is_nothrow_copy_constructible_v<_Tp>) + requires copyable<_Tp> struct __box<_Tp> { private: @@ -174,38 +173,6 @@ namespace ranges : _M_value(std::forward<_Args>(__args)...) { } - __box(const __box&) = default; - __box(__box&&) = default; - __box& operator=(const __box&) requires copyable<_Tp> = default; - __box& operator=(__box&&) requires copyable<_Tp> = default; - - // When _Tp is nothrow_copy_constructible but not copy_assignable, - // copy assignment is implemented via destroy-then-copy-construct. - constexpr __box& - operator=(const __box& __that) noexcept - { - static_assert(is_nothrow_copy_constructible_v<_Tp>); - if (this != std::__addressof(__that)) - { - _M_value.~_Tp(); - std::construct_at(std::__addressof(_M_value), *__that); - } - return *this; - } - - // Likewise for move assignment. - constexpr __box& - operator=(__box&& __that) noexcept - { - static_assert(is_nothrow_move_constructible_v<_Tp>); - if (this != std::__addressof(__that)) - { - _M_value.~_Tp(); - std::construct_at(std::__addressof(_M_value), std::move(*__that)); - } - return *this; - } - constexpr bool has_value() const noexcept { return true; }; @@ -1180,16 +1147,6 @@ namespace views::__adaptor return *this; } - constexpr __non_propagating_cache& - operator=(_Tp __val) - { - this->_M_reset(); - std::construct_at(std::__addressof(this->_M_payload._M_payload), - std::in_place, std::move(__val)); - this->_M_payload._M_engaged = true; - return *this; - } - constexpr _Tp& operator*() noexcept { return this->_M_get(); } @@ -2886,7 +2843,7 @@ namespace views::__adaptor if constexpr (forward_range<_Vp>) return _M_current; else - return *_M_parent->_M_current; + return _M_parent->_M_current; } constexpr auto& @@ -2895,7 +2852,7 @@ namespace views::__adaptor if constexpr (forward_range<_Vp>) return _M_current; else - return *_M_parent->_M_current; + return _M_parent->_M_current; } _Parent* _M_parent = nullptr; @@ -3143,13 +3100,15 @@ namespace views::__adaptor // XXX: _M_current is "present only if !forward_range" [[no_unique_address]] __detail::__maybe_present_t, - __detail::__non_propagating_cache>> _M_current; + iterator_t<_Vp>> _M_current; _Vp _M_base = _Vp(); public: split_view() requires (default_initializable<_Vp> - && default_initializable<_Pattern>) + && default_initializable<_Pattern> + && (forward_range<_Vp> + || default_initializable>)) = default; constexpr diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/detail/copyable_box.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/detail/copyable_box.cc index fa6d4d56816..2078d442447 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/detail/copyable_box.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/detail/copyable_box.cc @@ -101,6 +101,9 @@ test02() __box> x1(std::in_place, 0, 0); } +#if 0 +// On the 11 branch, the partial specialization of __box admits only copyable types +// so this test doesn't apply. constexpr bool test03() { @@ -142,3 +145,4 @@ test03() return true; } static_assert(test03()); +#endif