public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10466] libstdc++: missing constexpr for __[nm]iter_base [PR102358]
@ 2022-02-17 13:04 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-02-17 13:04 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:f9982b5a81a151663c76ba0a3fb6df674f29ba4b

commit r10-10466-gf9982b5a81a151663c76ba0a3fb6df674f29ba4b
Author: Patrick Palka <ppalka@redhat.com>
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 8857813e691..85e58973ac6 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -2276,6 +2276,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// @} group iterators
 
   template<typename _Iterator>
+    _GLIBCXX20_CONSTEXPR
     auto
     __niter_base(move_iterator<_Iterator> __it)
     -> decltype(make_move_iterator(__niter_base(__it.base())))
@@ -2289,6 +2290,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   template<typename _Iterator>
+    _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 <algorithm>
+#include <span>
+
+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());


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-17 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 13:04 [gcc r10-10466] libstdc++: missing constexpr for __[nm]iter_base [PR102358] Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).