mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-20 01:25:03 +08:00
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.
This commit is contained in:
parent
9262ae450d
commit
5f7976f65b
@ -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()))
|
||||
|
19
libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc
Normal file
19
libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc
Normal file
@ -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());
|
Loading…
Reference in New Issue
Block a user