summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-10-21 12:13:35 -0400
committerPatrick Palka <ppalka@redhat.com>2021-10-21 12:13:35 -0400
commit5f7976f65b45c457b57bfc2c55ec845771e0d3c2 (patch)
tree975c5044209326f7bccca48bf28eafbd3b2ce3b5 /libstdc++-v3
parent9262ae450d6a57837c58645c2ee66365bbe08338 (diff)
downloadgcc-5f7976f65b45c457b57bfc2c55ec845771e0d3c2.tar.gz
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.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/bits/stl_iterator.h2
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc19
2 files changed, 21 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 0090b2d598f..f6504ece560 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -2472,6 +2472,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())))
@@ -2485,6 +2486,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());