diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-05-26 12:41:03 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-05-26 17:14:40 +0100 |
commit | 47b20d027ade5bfbd932724d0ea2aedee7421243 (patch) | |
tree | 4c0920e66d2be2518a491d04e28870cceaeca3a8 /libstdc++-v3/testsuite | |
parent | 97dc78d705a90c1ae83c78a7f2e24942cc3a6257 (diff) |
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.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3643.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3643.cc b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3643.cc new file mode 100644 index 00000000000..e6f12b46c12 --- /dev/null +++ b/libstdc++-v3/testsuite/24_iterators/counted_iterator/lwg3643.cc @@ -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() ); |