From 247f410b83797a1840573840cc2a539ef9d7f96b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 19 Feb 2020 14:00:59 +0000 Subject: [PATCH] libstdc++: Remove std::span::cbegin and std::span::cend (LWG 3320) * include/std/span (span::const_iterator, span::const_reverse_iterator) (span::cbegin(), span::cend(), span::crbegin(), span::crend()): Remove (LWG 3320). * testsuite/23_containers/span/everything.cc: Replace uses of cbegin and cend. * testsuite/20_util/specialized_algorithms/destroy/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_copy/ constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/ uninitialized_default_construct/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_fill/ constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_move/ constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/ uninitialized_value_construct/constrained.cc: Likewise. --- libstdc++-v3/ChangeLog | 18 ++++++++++++++++++ libstdc++-v3/include/std/span | 18 ------------------ .../destroy/constrained.cc | 4 ++-- .../uninitialized_copy/constrained.cc | 18 +++++++++--------- .../constrained.cc | 8 ++++---- .../uninitialized_fill/constrained.cc | 8 ++++---- .../uninitialized_move/constrained.cc | 18 +++++++++--------- .../constrained.cc | 8 ++++---- .../testsuite/23_containers/span/everything.cc | 15 +++++++-------- 9 files changed, 57 insertions(+), 58 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f01b78da118..f5f8b6fd500 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,23 @@ 2020-02-19 Jonathan Wakely + * include/std/span (span::const_iterator, span::const_reverse_iterator) + (span::cbegin(), span::cend(), span::crbegin(), span::crend()): + Remove (LWG 3320). + * testsuite/23_containers/span/everything.cc: Replace uses of cbegin + and cend. + * testsuite/20_util/specialized_algorithms/destroy/constrained.cc: + Likewise. + * testsuite/20_util/specialized_algorithms/uninitialized_copy/ + constrained.cc: Likewise. + * testsuite/20_util/specialized_algorithms/ + uninitialized_default_construct/constrained.cc: Likewise. + * testsuite/20_util/specialized_algorithms/uninitialized_fill/ + constrained.cc: Likewise. + * testsuite/20_util/specialized_algorithms/uninitialized_move/ + constrained.cc: Likewise. + * testsuite/20_util/specialized_algorithms/ + uninitialized_value_construct/constrained.cc: Likewise. + * include/bits/range_access.h (range_size_t): Define alias template. * include/std/ranges (all_view): Rename to views::all_t (LWG 3335). * testsuite/std/ranges/adaptors/filter.cc: Adjust to new name. diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index 63dc2515b25..ccfd7db39fe 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -141,9 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using reference = element_type&; using const_reference = const element_type&; using iterator = __gnu_cxx::__normal_iterator; - using const_iterator = __gnu_cxx::__normal_iterator; using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; // member constants static constexpr size_t extent = _Extent; @@ -297,34 +295,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION begin() const noexcept { return iterator(this->_M_ptr); } - constexpr const_iterator - cbegin() const noexcept - { return const_iterator(this->_M_ptr); } - constexpr iterator end() const noexcept { return iterator(this->_M_ptr + this->size()); } - constexpr const_iterator - cend() const noexcept - { return const_iterator(this->_M_ptr + this->size()); } - constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(this->end()); } - constexpr const_reverse_iterator - crbegin() const noexcept - { return const_reverse_iterator(this->cend()); } - constexpr reverse_iterator rend() const noexcept { return reverse_iterator(this->begin()); } - constexpr const_reverse_iterator - crend() const noexcept - { return const_reverse_iterator(this->cbegin()); } - // subviews template diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc index 730625d9a21..c04049de0b5 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc @@ -54,7 +54,7 @@ test01() ranges::uninitialized_default_construct(rx); VERIFY( X::count == size ); - auto i = rx.cbegin(); + auto i = rx.begin(); if (k == 0) i = ranges::destroy(rx); else if (k == 1) @@ -64,7 +64,7 @@ test01() else __builtin_abort(); - VERIFY( i == rx.cend() ); + VERIFY( i == rx.end() ); VERIFY( X::count == 0 ); } } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc index 948406432cb..c1a50c45df9 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc @@ -47,7 +47,7 @@ test01(const std::vector &ix) auto buffer = std::unique_ptr(new char[sizeof(T)*size]); std::span rx((T *)buffer.get(), size); - ranges::uninitialized_copy_result res = {ix.cbegin(), rx.cbegin()}; + ranges::uninitialized_copy_result res = {ix.begin(), rx.begin()}; if (k == 0) res = ranges::uninitialized_copy(ix.begin(), ix.end(), rx.begin(), rx.end()); @@ -58,33 +58,33 @@ test01(const std::vector &ix) rx.begin(), rx.end()); else if (k == 3) res = ranges::uninitialized_copy(ix.begin(), ix.end(), - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 4) res = ranges::uninitialized_copy(ix, std::as_const(rx)); else if (k == 5) res = ranges::uninitialized_copy_n(ix.begin(), size, - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 6) res = ranges::uninitialized_copy_n(ix.begin(), size/2, - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 7) res = ranges::uninitialized_copy_n(ix.begin(), size, - rx.cbegin(), rx.cbegin()+size/2); + rx.begin(), rx.begin()+size/2); else __builtin_abort(); if (k == 6 || k == 7) { - VERIFY( ranges::distance(ix.cbegin(), res.in) == size/2 ); - VERIFY( ranges::distance(rx.cbegin(), res.out) == size/2 ); + VERIFY( ranges::distance(ix.begin(), res.in) == size/2 ); + VERIFY( ranges::distance(rx.begin(), res.out) == size/2 ); VERIFY( ranges::equal(ix.begin(), ix.begin()+size/2, rx.begin(), rx.begin()+size/2) ); ranges::destroy(rx.begin(), rx.begin()+size/2); } else { - VERIFY( res.in == ix.cend() ); - VERIFY( res.out == rx.cend() ); + VERIFY( res.in == ix.end() ); + VERIFY( res.out == rx.end() ); VERIFY( ranges::equal(ix, rx) ); ranges::destroy(rx); } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc index 6ef24cc7ea0..d6ccfc7c7e4 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc @@ -53,7 +53,7 @@ test01() ranges::fill(rx, t); } - auto i = rx.cbegin(); + auto i = rx.begin(); if (k == 0) i = ranges::uninitialized_default_construct(rx.begin(), rx.end()); else if (k == 1) @@ -63,15 +63,15 @@ test01() else if constexpr (std::is_fundamental_v) continue; else if (k == 3) - i = ranges::uninitialized_default_construct(rx.cbegin(), rx.cend()); + i = ranges::uninitialized_default_construct(rx.begin(), rx.end()); else if (k == 4) i = ranges::uninitialized_default_construct(std::as_const(rx)); else if (k == 5) - i = ranges::uninitialized_default_construct_n(rx.cbegin(), 1024); + i = ranges::uninitialized_default_construct_n(rx.begin(), 1024); else __builtin_abort(); - VERIFY( i == rx.cend() ); + VERIFY( i == rx.end() ); VERIFY( ranges::find_if(rx, [&t](const T& v) { return t != v; }) == i ); ranges::destroy(rx); diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc index c95fd666942..0fbbd1fa49f 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc @@ -45,7 +45,7 @@ test01(const T& value) auto buffer = std::unique_ptr(new char[sizeof(T)*size]); std::span rx((T *)buffer.get(), size); - auto i = rx.cbegin(); + auto i = rx.begin(); if (k == 0) i = ranges::uninitialized_fill(rx.begin(), rx.end(), value); else if (k == 1) @@ -53,15 +53,15 @@ test01(const T& value) else if (k == 2) i = ranges::uninitialized_fill_n(rx.begin(), 1024, value); else if (k == 3) - i = ranges::uninitialized_fill(rx.cbegin(), rx.cend(), value); + i = ranges::uninitialized_fill(rx.begin(), rx.end(), value); else if (k == 4) i = ranges::uninitialized_fill(std::as_const(rx), value); else if (k == 5) - i = ranges::uninitialized_fill_n(rx.cbegin(), 1024, value); + i = ranges::uninitialized_fill_n(rx.begin(), 1024, value); else __builtin_abort(); - VERIFY( i == rx.cend() ); + VERIFY( i == rx.end() ); VERIFY( ranges::find_if(rx, [&value](const T& v) { return value != v; }) == i ); ranges::destroy(rx); diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc index 796c7ca8f46..a7d6fd39b38 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc @@ -51,7 +51,7 @@ test01(std::vector ix) auto buffer = std::unique_ptr(new char[sizeof(T)*size]); std::span rx((T *)buffer.get(), size); - ranges::uninitialized_move_result res = {ix.cbegin(), rx.cbegin()}; + ranges::uninitialized_move_result res = {ix.begin(), rx.begin()}; if (k == 0) res = ranges::uninitialized_move(ix.begin(), ix.end(), rx.begin(), rx.end()); @@ -62,33 +62,33 @@ test01(std::vector ix) rx.begin(), rx.end()); else if (k == 3) res = ranges::uninitialized_move(ix.begin(), ix.end(), - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 4) res = ranges::uninitialized_move(ix, std::as_const(rx)); else if (k == 5) res = ranges::uninitialized_move_n(ix.begin(), size, - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 6) res = ranges::uninitialized_move_n(ix.begin(), size/2, - rx.cbegin(), rx.cend()); + rx.begin(), rx.end()); else if (k == 7) res = ranges::uninitialized_move_n(ix.begin(), size, - rx.cbegin(), rx.cbegin()+size/2); + rx.begin(), rx.begin()+size/2); else __builtin_abort(); if (k == 6 || k == 7) { - VERIFY( ranges::distance(ix.cbegin(), res.in) == size/2 ); - VERIFY( ranges::distance(rx.cbegin(), res.out) == size/2 ); + VERIFY( ranges::distance(ix.begin(), res.in) == size/2 ); + VERIFY( ranges::distance(rx.begin(), res.out) == size/2 ); VERIFY( ranges::equal(saved_ix.begin(), saved_ix.begin()+size/2, rx.begin(), rx.begin()+size/2) ); ranges::destroy(rx.begin(), rx.begin()+size/2); } else { - VERIFY( res.in == ix.cend() ); - VERIFY( res.out == rx.cend() ); + VERIFY( res.in == ix.end() ); + VERIFY( res.out == rx.end() ); VERIFY( ranges::equal(saved_ix, rx) ); ranges::destroy(rx); } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc index 5928bc04c70..ba3799b103e 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc @@ -48,7 +48,7 @@ test01() T t{}; - auto i = rx.cbegin(); + auto i = rx.begin(); if (k == 0) i = ranges::uninitialized_value_construct(rx.begin(), rx.end()); else if (k == 1) @@ -56,15 +56,15 @@ test01() else if (k == 2) i = ranges::uninitialized_value_construct_n(rx.begin(), 1024); else if (k == 3) - i = ranges::uninitialized_value_construct(rx.cbegin(), rx.cend()); + i = ranges::uninitialized_value_construct(rx.begin(), rx.end()); else if (k == 4) i = ranges::uninitialized_value_construct(std::as_const(rx)); else if (k == 5) - i = ranges::uninitialized_value_construct_n(rx.cbegin(), 1024); + i = ranges::uninitialized_value_construct_n(rx.begin(), 1024); else __builtin_abort(); - VERIFY( i == rx.cend() ); + VERIFY( i == rx.end() ); VERIFY( ranges::find_if(rx, [&t](const T& v) { return t != v; }) == i ); ranges::destroy(rx); diff --git a/libstdc++-v3/testsuite/23_containers/span/everything.cc b/libstdc++-v3/testsuite/23_containers/span/everything.cc index 0cca06fa4fe..0ae4d741d0e 100644 --- a/libstdc++-v3/testsuite/23_containers/span/everything.cc +++ b/libstdc++-v3/testsuite/23_containers/span/everything.cc @@ -162,9 +162,8 @@ main() bool really_empty1 = std::empty(shorts); bool really_empty2 = shorts.data() == nullptr; bool really_empty3 = shorts.begin() == shorts.end(); - bool really_empty4 = shorts.cbegin() == shorts.cend(); bool really_empty = - really_empty0 && really_empty1 && really_empty2 && really_empty3 && really_empty4; + really_empty0 && really_empty1 && really_empty2 && really_empty3; (void)really_empty; VERIFY(really_empty); @@ -179,10 +178,10 @@ main() std::span muh_byte_span = std::as_bytes(muh_span); std::span muh_mutable_byte_span = std::as_writable_bytes(muh_span); std::span muh_original_byte_span(original_bytes, original_bytes + 4); - bool definitely_reinterpret_casted0 = std::equal(muh_byte_span.cbegin(), muh_byte_span.cend(), - muh_original_byte_span.cbegin(), muh_original_byte_span.cend()); - bool definitely_reinterpret_casted1 = std::equal(muh_mutable_byte_span.cbegin(), - muh_mutable_byte_span.cend(), muh_original_byte_span.cbegin(), muh_original_byte_span.cend()); + bool definitely_reinterpret_casted0 = std::equal(muh_byte_span.begin(), muh_byte_span.end(), + muh_original_byte_span.begin(), muh_original_byte_span.end()); + bool definitely_reinterpret_casted1 = std::equal(muh_mutable_byte_span.begin(), + muh_mutable_byte_span.end(), muh_original_byte_span.begin(), muh_original_byte_span.end()); bool definitely_reinterpret_casted = definitely_reinterpret_casted0 && definitely_reinterpret_casted1; (void)definitely_reinterpret_casted; @@ -190,8 +189,8 @@ main() std::span muh_original_byte_span_ptr_size(original_bytes, 4); bool definitely_equivalent = - std::equal(muh_original_byte_span_ptr_size.cbegin(), muh_original_byte_span_ptr_size.cend(), - muh_original_byte_span.cbegin(), muh_original_byte_span.cend()); + std::equal(muh_original_byte_span_ptr_size.begin(), muh_original_byte_span_ptr_size.end(), + muh_original_byte_span.begin(), muh_original_byte_span.end()); (void)definitely_equivalent; VERIFY(definitely_equivalent); -- 2.30.2