From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 99BE23858D20; Thu, 17 Feb 2022 13:03:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99BE23858D20 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-9588] libstdc++: missing constexpr for __[nm]iter_base [PR102358] X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 6d9c2ed02128ddf327465333f5563500b6cf8886 X-Git-Newrev: 973e0bc1542dd5efc501fef8653d47c9b00adf97 Message-Id: <20220217130301.99BE23858D20@sourceware.org> Date: Thu, 17 Feb 2022 13:03:01 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2022 13:03:01 -0000 https://gcc.gnu.org/g:973e0bc1542dd5efc501fef8653d47c9b00adf97 commit r11-9588-g973e0bc1542dd5efc501fef8653d47c9b00adf97 Author: Patrick Palka Date: Thu Oct 21 12:13:35 2021 -0400 libstdc++: missing constexpr for __[nm]iter_base [PR102358] PR libstdc++/102358 libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__niter_base): Make constexpr for C++20. (__miter_base): Likewise. * testsuite/25_algorithms/move/constexpr.cc: New test. (cherry picked from commit 5f7976f65b45c457b57bfc2c55ec845771e0d3c2) Diff: --- libstdc++-v3/include/bits/stl_iterator.h | 2 ++ .../testsuite/25_algorithms/move/constexpr.cc | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 549bc26dee5..2b7efcbf3c3 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -2338,6 +2338,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @} group iterators template + _GLIBCXX20_CONSTEXPR auto __niter_base(move_iterator<_Iterator> __it) -> decltype(make_move_iterator(__niter_base(__it.base()))) @@ -2351,6 +2352,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template + _GLIBCXX20_CONSTEXPR auto __miter_base(move_iterator<_Iterator> __it) -> decltype(__miter_base(__it.base())) diff --git a/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc new file mode 100644 index 00000000000..773c55cfb50 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +#include +#include + +constexpr bool +test01() +{ + // PR libstdc++/102358 + int x[2] = {1,2}, y[2]; + std::span in(x), out(y); + std::move(std::move_iterator(in.begin()), std::move_iterator(in.end()), + out.begin()); + return std::equal(std::move_iterator(in.begin()), std::move_iterator(in.end()), + std::move_iterator(out.begin())); +} + +static_assert(test01());