mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-18 16:44:57 +08:00
libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
Add 'constexpr' as per LWG 3643.
* testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.
(cherry picked from commit 47b20d027a
)
This commit is contained in:
parent
5647e401bb
commit
7be1dd924d
@ -2341,7 +2341,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
return *this;
|
||||
}
|
||||
|
||||
decltype(auto)
|
||||
constexpr decltype(auto)
|
||||
operator++(int)
|
||||
{
|
||||
__glibcxx_assert(_M_length > 0);
|
||||
@ -2353,7 +2353,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
++_M_length;
|
||||
__throw_exception_again;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
constexpr counted_iterator
|
||||
|
@ -0,0 +1,27 @@
|
||||
// { dg-options "-std=gnu++20" }
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
struct InputIterator
|
||||
{
|
||||
using difference_type = int;
|
||||
using value_type = int;
|
||||
|
||||
constexpr int operator*() const noexcept { return 0; }
|
||||
InputIterator& operator++() { return *this; }
|
||||
constexpr void operator++(int) { }
|
||||
};
|
||||
|
||||
static_assert( std::input_iterator<InputIterator> );
|
||||
static_assert( !std::forward_iterator<InputIterator> );
|
||||
|
||||
constexpr bool
|
||||
test_lwg3643()
|
||||
{
|
||||
std::counted_iterator<InputIterator> iter({}, 1);
|
||||
iter++;
|
||||
return iter == std::default_sentinel;
|
||||
}
|
||||
|
||||
static_assert( test_lwg3643() );
|
Loading…
Reference in New Issue
Block a user