libstdc++: Remove std::span::cbegin and std::span::cend (LWG 3320)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 19 Feb 2020 14:00:59 +0000 (14:00 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 19 Feb 2020 15:27:49 +0000 (15:27 +0000)
* 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
libstdc++-v3/include/std/span
libstdc++-v3/testsuite/20_util/specialized_algorithms/destroy/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc
libstdc++-v3/testsuite/23_containers/span/everything.cc

index f01b78da1180f4ec71815df41b32ca26dcbe6c81..f5f8b6fd5001bb511a4ece44df52a579fe56b800 100644 (file)
@@ -1,5 +1,23 @@
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+       * 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.
index 63dc2515b25ec482392a5351d6def110578107e0..ccfd7db39fef7e65bd5389d98980b28ddb54aaa7 100644 (file)
@@ -141,9 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       using reference              = element_type&;
       using const_reference        = const element_type&;
       using iterator = __gnu_cxx::__normal_iterator<pointer, span>;
-      using const_iterator = __gnu_cxx::__normal_iterator<const_pointer, span>;
       using reverse_iterator       = std::reverse_iterator<iterator>;
-      using const_reverse_iterator = std::reverse_iterator<const_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<size_t _Count>
index 730625d9a21d62dc15f6de3fefa13cd33c0cf68a..c04049de0b5e481d4b7a8e94f5a9a77f60131210 100644 (file)
@@ -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 );
     }
 }
index 948406432cba537916e3d5f629b22cabfab43bca..c1a50c45df9c2668da6681c7ba4f1f64d3f06590 100644 (file)
@@ -47,7 +47,7 @@ test01(const std::vector<T> &ix)
       auto buffer = std::unique_ptr<char[]>(new char[sizeof(T)*size]);
       std::span<T> 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<T> &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);
        }
index 6ef24cc7ea07fc59a11cced82863e8707c272b1f..d6ccfc7c7e48b897c3ee60079175b4f64a5445ea 100644 (file)
@@ -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<T>)
        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);
index c95fd666942ea1ce7e0f8050bc2d8e949080c5ea..0fbbd1fa49f335aace1c7ab1904c77c8d33e971c 100644 (file)
@@ -45,7 +45,7 @@ test01(const T& value)
       auto buffer = std::unique_ptr<char[]>(new char[sizeof(T)*size]);
       std::span<T> 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);
index 796c7ca8f4668bc60ef0ce4413a006cb8b9d8f9d..a7d6fd39b3848f8c7f2a47405622f2e5223cbd90 100644 (file)
@@ -51,7 +51,7 @@ test01(std::vector<T> ix)
       auto buffer = std::unique_ptr<char[]>(new char[sizeof(T)*size]);
       std::span<T> 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<T> 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);
        }
index 5928bc04c705315c7a1597007f51a3229d596b50..ba3799b103ebec4e94ff5de801cf8c7bb42f810e 100644 (file)
@@ -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);
index 0cca06fa4fe63e343c8cfe98419674425e54f679..0ae4d741d0e0996fc352126aca5bffe9407c29cc 100644 (file)
@@ -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<const std::byte> muh_byte_span   = std::as_bytes(muh_span);
   std::span<std::byte> muh_mutable_byte_span = std::as_writable_bytes(muh_span);
   std::span<std::byte> 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<std::byte> 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);