Apply C++20 changes to various iterator types
authorJonathan Wakely <jwakely@redhat.com>
Wed, 30 Oct 2019 15:48:11 +0000 (15:48 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 30 Oct 2019 15:48:11 +0000 (15:48 +0000)
This ensures that __normal_iterator<T*, C> satisfies the
contiguous_iterator concept, by defining the iterator_concept member
type.

Also update vector<bool>'s iterators, reverse_iterator,
istreambuf_iterator and ostreambuf_iterator to meet the C++20
requirements.

PR libstdc++/92272
* include/bits/stl_bvector.h (_Bit_iterator::pointer)
(_Bit_const_iterator::pointer): Define as void for C++20.
* include/bits/stl_iterator.h (reverse_iterator::operator->()): Add
constraints for C++20.
(__normal_iterator::iterator_concept): Define for C++20.
* include/bits/streambuf_iterator.h (istreambuf_iterator::pointer):
Define as void for C++20.
(ostreambuf_iterator::difference_type): Define as ptrdiff_t for C++20.
(ostreambuf_iterator::ostreambuf_iterator()): Add default constructor
for C++20.
* testsuite/23_containers/vector/bool/iterator_c++20.cc: New test.
* testsuite/24_iterators/bidirectional/concept.cc: New test.
* testsuite/24_iterators/bidirectional/tag.cc: New test.
* testsuite/24_iterators/contiguous/concept.cc: New test.
* testsuite/24_iterators/contiguous/tag.cc: New test.
* testsuite/24_iterators/forward/concept.cc: New test.
* testsuite/24_iterators/forward/tag.cc: New test.
* testsuite/24_iterators/input/concept.cc: New test.
* testsuite/24_iterators/input/tag.cc: New test.
* testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc:
New test.
* testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc:
New test.
* testsuite/24_iterators/output/concept.cc: New test.
* testsuite/24_iterators/output/tag.cc: New test.
* testsuite/24_iterators/random_access/concept.cc: New test.
* testsuite/24_iterators/random_access/tag.cc: New test.
* testsuite/24_iterators/range_operations/advance_debug_neg.cc: New
test.
* testsuite/24_iterators/random_access_iterator/26020.cc: Move to ...
* testsuite/24_iterators/operations/26020.cc: ... here.
* testsuite/24_iterators/random_access_iterator/
string_vector_iterators.cc: Move to ...
* testsuite/24_iterators/random_access/string_vector_iterators.cc: ...
here.

From-SVN: r277629

24 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/include/bits/streambuf_iterator.h
libstdc++-v3/testsuite/23_containers/vector/bool/iterator_c++20.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/bidirectional/concept.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/bidirectional/tag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/contiguous/concept.cc
libstdc++-v3/testsuite/24_iterators/contiguous/tag.cc
libstdc++-v3/testsuite/24_iterators/forward/concept.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/forward/tag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/input/concept.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/input/tag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc
libstdc++-v3/testsuite/24_iterators/operations/26020.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc
libstdc++-v3/testsuite/24_iterators/output/concept.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/output/tag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/random_access/concept.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/random_access/string_vector_iterators.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/random_access/tag.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/random_access_iterator/26020.cc [deleted file]
libstdc++-v3/testsuite/24_iterators/random_access_iterator/string_vector_iterators.cc [deleted file]
libstdc++-v3/testsuite/24_iterators/range_operations/advance_debug_neg.cc [new file with mode: 0644]

index ad736788106999194f6b9fec3c707f2afd82665f..12eca8f8138c9a7eab3333615c41bf3dc280c525 100644 (file)
@@ -1,5 +1,42 @@
 2019-10-30  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/92272
+       * include/bits/stl_bvector.h (_Bit_iterator::pointer)
+       (_Bit_const_iterator::pointer): Define as void for C++20.
+       * include/bits/stl_iterator.h (reverse_iterator::operator->()): Add
+       constraints for C++20.
+       (__normal_iterator::iterator_concept): Define for C++20.
+       * include/bits/streambuf_iterator.h (istreambuf_iterator::pointer):
+       Define as void for C++20.
+       (ostreambuf_iterator::difference_type): Define as ptrdiff_t for C++20.
+       (ostreambuf_iterator::ostreambuf_iterator()): Add default constructor
+       for C++20.
+       * testsuite/23_containers/vector/bool/iterator_c++20.cc: New test.
+       * testsuite/24_iterators/bidirectional/concept.cc: New test.
+       * testsuite/24_iterators/bidirectional/tag.cc: New test.
+       * testsuite/24_iterators/contiguous/concept.cc: New test.
+       * testsuite/24_iterators/contiguous/tag.cc: New test.
+       * testsuite/24_iterators/forward/concept.cc: New test.
+       * testsuite/24_iterators/forward/tag.cc: New test.
+       * testsuite/24_iterators/input/concept.cc: New test.
+       * testsuite/24_iterators/input/tag.cc: New test.
+       * testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc:
+       New test.
+       * testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc:
+       New test.
+       * testsuite/24_iterators/output/concept.cc: New test.
+       * testsuite/24_iterators/output/tag.cc: New test.
+       * testsuite/24_iterators/random_access/concept.cc: New test.
+       * testsuite/24_iterators/random_access/tag.cc: New test.
+       * testsuite/24_iterators/range_operations/advance_debug_neg.cc: New
+       test.
+       * testsuite/24_iterators/random_access_iterator/26020.cc: Move to ...
+       * testsuite/24_iterators/operations/26020.cc: ... here.
+       * testsuite/24_iterators/random_access_iterator/
+       string_vector_iterators.cc: Move to ...
+       * testsuite/24_iterators/random_access/string_vector_iterators.cc: ...
+       here.
+
        * testsuite/util/testsuite_iterators.h: Fix typo in __cplusplus check.
 
 2019-10-29  Jonathan Wakely  <jwakely@redhat.com>
index 280d40f60c51fbe16bef5691515b521d0b4e049b..f2eea7799dca090a3d2c18bf27c2474aacbdf3e6 100644 (file)
@@ -220,7 +220,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   struct _Bit_iterator : public _Bit_iterator_base
   {
     typedef _Bit_reference  reference;
+#if __cplusplus > 201703L
+    typedef void           pointer;
+#else
     typedef _Bit_reference* pointer;
+#endif
     typedef _Bit_iterator   iterator;
 
     _Bit_iterator() : _Bit_iterator_base(0, 0) { }
@@ -309,7 +313,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   {
     typedef bool                 reference;
     typedef bool                 const_reference;
+#if __cplusplus > 201703L
+    typedef void           pointer;
+#else
     typedef const bool*          pointer;
+#endif
     typedef _Bit_const_iterator  const_iterator;
 
     _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
index c10117e9b3810d0d24877d83280e8fec2bd6e580..2a3b023107970d3f917e19c77e8a791a100bb3b4 100644 (file)
@@ -187,6 +187,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       */
       _GLIBCXX17_CONSTEXPR pointer
       operator->() const
+#if __cplusplus > 201703L && defined __cpp_concepts
+      requires is_pointer_v<_Iterator>
+       || requires(const _Iterator __i) { __i.operator->(); }
+#endif
       {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 1052. operator-> should also support smart pointers
@@ -807,6 +811,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename __traits_type::reference        reference;
       typedef typename __traits_type::pointer          pointer;
 
+#if __cplusplus > 201703L
+      using iterator_concept = std::__detail::__iter_concept<_Iterator>;
+#endif
+
       _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
       : _M_current(_Iterator()) { }
 
index e3e8736e7682f1b900423296354a3828152063ac..077b11a5ff5d618a0a00ae1253038730a0ffda13 100644 (file)
@@ -61,6 +61,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // Types:
       //@{
       /// Public typedefs
+#if __cplusplus > 201703L
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 3188. istreambuf_iterator::pointer should not be unspecified
+      using pointer = void;
+#endif
       typedef _CharT                                   char_type;
       typedef _Traits                                  traits_type;
       typedef typename _Traits::int_type               int_type;
@@ -230,6 +235,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // Types:
       //@{
       /// Public typedefs
+#if __cplusplus > 201703L
+      using difference_type = ptrdiff_t;
+#endif
       typedef _CharT                          char_type;
       typedef _Traits                         traits_type;
       typedef basic_streambuf<_CharT, _Traits> streambuf_type;
@@ -247,6 +255,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool             _M_failed;
 
     public:
+
+#if __cplusplus > 201703L
+      constexpr
+      ostreambuf_iterator() noexcept
+      : _M_sbuf(nullptr), _M_failed(true) { }
+#endif
+
       ///  Construct output iterator from ostream.
       ostreambuf_iterator(ostream_type& __s) _GLIBCXX_USE_NOEXCEPT
       : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/iterator_c++20.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/iterator_c++20.cc
new file mode 100644 (file)
index 0000000..2a36d98
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <vector>
+
+// C++20 [iterator.traits]: The type iterator_traits<I>::pointer shall be void
+// for an iterator of class type I that does not support operator->.
+template<typename I>
+  concept arrow_or_no_pointer = requires (I i) { i.operator->(); }
+    || std::same_as<typename std::iterator_traits<I>::pointer, void>;
+
+static_assert( arrow_or_no_pointer<std::vector<bool>::iterator> );
+static_assert( arrow_or_no_pointer<std::vector<bool>::const_iterator> );
diff --git a/libstdc++-v3/testsuite/24_iterators/bidirectional/concept.cc b/libstdc++-v3/testsuite/24_iterators/bidirectional/concept.cc
new file mode 100644 (file)
index 0000000..0bcd6f5
--- /dev/null
@@ -0,0 +1,81 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <iterator>
+
+using std::bidirectional_iterator;
+
+static_assert( bidirectional_iterator< int*        > );
+static_assert( bidirectional_iterator< const int* > );
+static_assert( bidirectional_iterator< void**      > );
+
+static_assert( ! bidirectional_iterator< int* const    > );
+static_assert( ! bidirectional_iterator< const int* const      > );
+static_assert( ! bidirectional_iterator< void** const  > );
+
+static_assert( ! bidirectional_iterator< void*   > );
+static_assert( ! bidirectional_iterator< const void*     > );
+static_assert( ! bidirectional_iterator< volatile void* > );
+
+static_assert( ! bidirectional_iterator< void(*)() > );
+static_assert( ! bidirectional_iterator< void(&)() > );
+
+struct A;
+static_assert( ! bidirectional_iterator< void(A::*)() > );
+static_assert( ! bidirectional_iterator< int A::*      > );
+
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::forward_list;
+using std::list;
+using std::string;
+using std::string_view;
+using std::vector;
+
+struct B { };
+
+static_assert( bidirectional_iterator< array<int, 1>::iterator     > );
+static_assert( bidirectional_iterator< array<B, 1>::const_iterator  > );
+
+static_assert( bidirectional_iterator< deque<int>::iterator     > );
+static_assert( bidirectional_iterator< deque<B>::const_iterator > );
+
+static_assert( bidirectional_iterator< list<int>::iterator     > );
+static_assert( bidirectional_iterator< list<B>::const_iterator > );
+
+static_assert( ! bidirectional_iterator< forward_list<int>::iterator      > );
+static_assert( ! bidirectional_iterator< forward_list<B>::const_iterator  > );
+
+static_assert( bidirectional_iterator< string::iterator              > );
+static_assert( bidirectional_iterator< string::const_iterator > );
+
+static_assert( bidirectional_iterator< string_view::iterator       > );
+static_assert( bidirectional_iterator< string_view::const_iterator  > );
+
+static_assert( bidirectional_iterator< vector<int>::iterator     > );
+static_assert( bidirectional_iterator< vector<B>::const_iterator  > );
diff --git a/libstdc++-v3/testsuite/24_iterators/bidirectional/tag.cc b/libstdc++-v3/testsuite/24_iterators/bidirectional/tag.cc
new file mode 100644 (file)
index 0000000..9b24b31
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <iterator>
+
+using std::bidirectional_iterator_tag;
+using std::forward_iterator_tag;
+using std::iterator_traits;
+
+static_assert( std::is_empty<bidirectional_iterator_tag>::value );
+static_assert( std::is_trivially_copy_constructible<bidirectional_iterator_tag>::value );
+
+static_assert( std::is_base_of<forward_iterator_tag,
+                              bidirectional_iterator_tag>::value );
+static_assert( std::is_convertible<bidirectional_iterator_tag*,
+                                  forward_iterator_tag*>::value );
index a9bb42e023f4c02cebefe64f09df39892f43ab00..0f9419aaba1ec254527416944fc3c6ccb5c93644 100644 (file)
 
 #include <iterator>
 
-static_assert( std::contiguous_iterator<int*> );
-static_assert( std::contiguous_iterator<const int*> );
-static_assert( std::contiguous_iterator<void**> );
+using std::contiguous_iterator;
 
-static_assert( ! std::contiguous_iterator<void*> );
-static_assert( ! std::contiguous_iterator<const void*> );
-static_assert( ! std::contiguous_iterator<volatile void*> );
+static_assert( contiguous_iterator< int*           > );
+static_assert( contiguous_iterator< const int* > );
+static_assert( contiguous_iterator< void**         > );
 
-static_assert( ! std::contiguous_iterator<void(*)()> );
-static_assert( ! std::contiguous_iterator<void(*)()> );
+static_assert( ! contiguous_iterator< int* const       > );
+static_assert( ! contiguous_iterator< const int* const > );
+static_assert( ! contiguous_iterator< void** const     > );
+
+static_assert( ! contiguous_iterator< void*      > );
+static_assert( ! contiguous_iterator< const void*        > );
+static_assert( ! contiguous_iterator< volatile void* > );
+
+static_assert( ! contiguous_iterator< void(*)() > );
+static_assert( ! contiguous_iterator< void(&)() > );
+static_assert( contiguous_iterator< void(**)() > );
 
 struct A;
-static_assert( ! std::contiguous_iterator<void(A::*)()> );
-static_assert( ! std::contiguous_iterator<int A::*> );
+static_assert( ! contiguous_iterator< void(A::*)() > );
+static_assert( ! contiguous_iterator< int A::* > );
+
+#include <array>
+#include <deque>
+#include <list>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::list;
+using std::string;
+using std::string_view;
+using std::vector;
+
+struct B { };
+
+static_assert( contiguous_iterator< array<int, 1>::iterator    > );
+static_assert( contiguous_iterator< array<B, 1>::const_iterator > );
+
+static_assert( ! contiguous_iterator< deque<int>::iterator     > );
+static_assert( ! contiguous_iterator< deque<B>::const_iterator > );
+
+static_assert( ! contiguous_iterator< list<int>::iterator      > );
+static_assert( ! contiguous_iterator< list<B>::const_iterator  > );
+
+static_assert( contiguous_iterator< string::iterator           > );
+static_assert( contiguous_iterator< string::const_iterator     > );
+
+static_assert( contiguous_iterator< string_view::iterator      > );
+static_assert( contiguous_iterator< string_view::const_iterator        > );
+
+static_assert( contiguous_iterator< vector<int>::iterator      > );
+static_assert( contiguous_iterator< vector<B>::const_iterator  > );
+
+static_assert( ! contiguous_iterator< vector<bool>::iterator       > );
+static_assert( ! contiguous_iterator< vector<bool>::const_iterator  > );
index 7673131f215f777816b1e59b247cb14747c8120d..8a0029c338be005c3f9eaff8f66029ae9953b894 100644 (file)
 
 #include <iterator>
 
+using std::contiguous_iterator_tag;
+using std::random_access_iterator_tag;
+using std::iterator_traits;
+
 static_assert( std::is_empty_v<std::contiguous_iterator_tag> );
 static_assert( std::is_trivially_copy_constructible_v<std::contiguous_iterator_tag> );
 
diff --git a/libstdc++-v3/testsuite/24_iterators/forward/concept.cc b/libstdc++-v3/testsuite/24_iterators/forward/concept.cc
new file mode 100644 (file)
index 0000000..4b125e5
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <iterator>
+
+using std::forward_iterator;
+
+static_assert( forward_iterator< int*      > );
+static_assert( forward_iterator< const int* > );
+static_assert( forward_iterator< void**            > );
+
+static_assert( ! forward_iterator< int* const  > );
+static_assert( ! forward_iterator< const int* const    > );
+static_assert( ! forward_iterator< void** const        > );
+
+static_assert( ! forward_iterator< void*         > );
+static_assert( ! forward_iterator< const void*   > );
+static_assert( ! forward_iterator< volatile void* > );
+
+static_assert( ! forward_iterator< void(*)() > );
+static_assert( ! forward_iterator< void(&)() > );
+
+struct A;
+static_assert( ! forward_iterator< void(A::*)() > );
+static_assert( ! forward_iterator< int A::*    > );
+
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::forward_list;
+using std::list;
+using std::string;
+using std::string_view;
+using std::vector;
+using std::istreambuf_iterator;
+using std::ostreambuf_iterator;
+
+struct B { };
+
+static_assert( forward_iterator< array<int, 1>::iterator      > );
+static_assert( forward_iterator< array<B, 1>::const_iterator  > );
+
+static_assert( forward_iterator< deque<int>::iterator    > );
+static_assert( forward_iterator< deque<B>::const_iterator > );
+
+static_assert( forward_iterator< forward_list<int>::iterator     > );
+static_assert( forward_iterator< forward_list<B>::const_iterator  > );
+
+static_assert( forward_iterator< list<int>::iterator     > );
+static_assert( forward_iterator< list<B>::const_iterator  > );
+
+static_assert( forward_iterator< string::iterator      > );
+static_assert( forward_iterator< string::const_iterator        > );
+
+static_assert( forward_iterator< string_view::iterator       > );
+static_assert( forward_iterator< string_view::const_iterator  > );
+
+static_assert( forward_iterator< vector<int>::iterator     > );
+static_assert( forward_iterator< vector<B>::const_iterator  > );
+
+static_assert( ! forward_iterator< istreambuf_iterator<char> > );
+static_assert( ! forward_iterator< ostreambuf_iterator<char> > );
diff --git a/libstdc++-v3/testsuite/24_iterators/forward/tag.cc b/libstdc++-v3/testsuite/24_iterators/forward/tag.cc
new file mode 100644 (file)
index 0000000..6ec3256
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <iterator>
+
+using std::forward_iterator_tag;
+using std::input_iterator_tag;
+using std::iterator_traits;
+
+static_assert( std::is_empty<forward_iterator_tag>::value );
+static_assert( std::is_trivially_copy_constructible<forward_iterator_tag>::value );
+
+static_assert( std::is_base_of<input_iterator_tag,
+                              forward_iterator_tag>::value );
+static_assert( std::is_convertible<forward_iterator_tag*,
+                                  input_iterator_tag*>::value );
diff --git a/libstdc++-v3/testsuite/24_iterators/input/concept.cc b/libstdc++-v3/testsuite/24_iterators/input/concept.cc
new file mode 100644 (file)
index 0000000..80bb679
--- /dev/null
@@ -0,0 +1,89 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <iterator>
+
+using std::input_iterator;
+
+static_assert( input_iterator< int*        > );
+static_assert( input_iterator< const int* > );
+static_assert( input_iterator< void**      > );
+
+static_assert( ! input_iterator< int* const    > );
+static_assert( ! input_iterator< const int* const      > );
+static_assert( ! input_iterator< void** const  > );
+
+static_assert( ! input_iterator< void*   > );
+static_assert( ! input_iterator< const void*     > );
+static_assert( ! input_iterator< volatile void* > );
+
+static_assert( ! input_iterator< void(*)() > );
+static_assert( ! input_iterator< void(&)() > );
+
+struct A;
+static_assert( ! input_iterator< void(A::*)() > );
+static_assert( ! input_iterator< int A::*      > );
+
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::forward_list;
+using std::list;
+using std::string;
+using std::string_view;
+using std::vector;
+
+struct B { };
+
+static_assert( input_iterator< array<int, 1>::iterator     > );
+static_assert( input_iterator< array<B, 1>::const_iterator  > );
+
+static_assert( input_iterator< deque<int>::iterator    > );
+static_assert( input_iterator< deque<B>::const_iterator        > );
+
+static_assert( input_iterator< forward_list<int>::iterator     > );
+static_assert( input_iterator< forward_list<B>::const_iterator > );
+
+static_assert( input_iterator< list<int>::iterator     > );
+static_assert( input_iterator< list<B>::const_iterator > );
+
+static_assert( input_iterator< string::iterator              > );
+static_assert( input_iterator< string::const_iterator > );
+
+static_assert( input_iterator< string_view::iterator       > );
+static_assert( input_iterator< string_view::const_iterator  > );
+
+static_assert( input_iterator< vector<int>::iterator     > );
+static_assert( input_iterator< vector<B>::const_iterator  > );
+
+#include <streambuf>
+
+using std::istreambuf_iterator;
+using std::ostreambuf_iterator;
+
+static_assert( input_iterator< istreambuf_iterator<char>    > );
+static_assert( ! input_iterator< ostreambuf_iterator<char>  > );
diff --git a/libstdc++-v3/testsuite/24_iterators/input/tag.cc b/libstdc++-v3/testsuite/24_iterators/input/tag.cc
new file mode 100644 (file)
index 0000000..ade01c4
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <iterator>
+
+using std::input_iterator_tag;
+using std::output_iterator_tag;
+using std::iterator_traits;
+
+static_assert( std::is_empty<input_iterator_tag>::value );
+static_assert( std::is_trivially_copy_constructible<input_iterator_tag>::value );
+
+static_assert( ! std::is_base_of<output_iterator_tag,
+                                input_iterator_tag>::value );
+static_assert( ! std::is_convertible<input_iterator_tag*,
+                                    output_iterator_tag*>::value );
index 59a99a52213ca408952af7e0a69d5c267d52e3d5..fcd703e592801987e3a9c1a4c97295e91eb6da59 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <sstream>
 #include <iterator>
-#include <testsuite_hooks.h>
 
 void test01()
 {
@@ -41,3 +40,53 @@ void test01()
   typedef test_iterator::istream_type istream_type;
   typedef test_iterator::streambuf_type streambuf_type;
 }
+
+#if __cplusplus >= 201103L
+void test02()
+{
+  using namespace std;
+
+  using test_type = istreambuf_iterator<char>;
+
+  static_assert(is_same<test_type::value_type, char>::value, "");
+  static_assert(is_same<test_type::difference_type,
+                         char_traits<char>::off_type>::value, "");
+#if __cplusplus <= 201703L
+  static_assert(is_same<test_type::pointer, char*>::value, "");
+#else
+  static_assert(is_same<test_type::pointer, void>::value, "");
+#endif
+  static_assert(is_same<test_type::reference, char>::value, "");
+  static_assert(is_same<test_type::iterator_category, input_iterator_tag>::value, "");
+
+  static_assert(is_same<test_type::char_type, char>::value, "");
+  static_assert(is_same<test_type::traits_type, char_traits<char>>::value, "");
+  static_assert(is_same<test_type::istream_type, istream>::value, "");
+  static_assert(is_same<test_type::streambuf_type, streambuf>::value, "");
+}
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+void test03()
+{
+  using namespace std;
+
+  using test_type = istreambuf_iterator<wchar_t>;
+
+  static_assert(is_same<test_type::value_type, wchar_t>::value, "");
+  static_assert(is_same<test_type::difference_type,
+                         char_traits<wchar_t>::off_type>::value, "");
+#if __cplusplus <= 201703L
+  static_assert(is_same<test_type::pointer, wchar_t*>::value, "");
+#else
+  static_assert(is_same<test_type::pointer, void>::value, "");
+#endif
+  static_assert(is_same<test_type::reference, wchar_t>::value, "");
+  static_assert(is_same<test_type::iterator_category, input_iterator_tag>::value, "");
+
+  static_assert(is_same<test_type::char_type, wchar_t>::value, "");
+  static_assert(is_same<test_type::traits_type, char_traits<wchar_t>>::value, "");
+  static_assert(is_same<test_type::istream_type, wistream>::value, "");
+  static_assert(is_same<test_type::streambuf_type, wstreambuf>::value, "");
+}
+#endif
+#endif
diff --git a/libstdc++-v3/testsuite/24_iterators/operations/26020.cc b/libstdc++-v3/testsuite/24_iterators/operations/26020.cc
new file mode 100644 (file)
index 0000000..ec23443
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2006-2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 24.3.4 Iterator operations
+
+#include <iterator>
+#include <list>
+#include <testsuite_hooks.h>
+
+//libstdc++/26020
+void test01()
+{
+  using namespace std;
+
+  list<int> ll;
+  ll.push_back(1);
+
+  list<int>::iterator it(ll.begin());
+
+  advance(it, 0.5);
+
+  VERIFY( it == ll.begin() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 51292b9d78373be2f5ef2bef0fc30b942eeedb6d..11813e39174f50789ec440cdc383aa9cc46484fa 100644 (file)
@@ -41,3 +41,49 @@ void test01()
   typedef test_iterator::ostream_type ostream_type;
   typedef test_iterator::streambuf_type streambuf_type;
 }
+
+#if __cplusplus >= 201103L
+void test02()
+{
+  using namespace std;
+
+  using test_type = ostreambuf_iterator<char>;
+  static_assert(is_same<test_type::value_type, void>::value, "");
+#if __cplusplus <= 201703L
+  static_assert(is_same<test_type::difference_type, void>::value, "");
+#else
+  static_assert(is_same<test_type::difference_type, ptrdiff_t>::value, "");
+#endif
+  static_assert(is_same<test_type::pointer, void>::value, "");
+  static_assert(is_same<test_type::reference, void>::value, "");
+  static_assert(is_same<test_type::iterator_category, output_iterator_tag>::value, "");
+
+  static_assert(is_same<test_type::char_type, char>::value, "");
+  static_assert(is_same<test_type::traits_type, char_traits<char>>::value, "");
+  static_assert(is_same<test_type::ostream_type, ostream>::value, "");
+  static_assert(is_same<test_type::streambuf_type, streambuf>::value, "");
+}
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+void test03()
+{
+  using namespace std;
+
+  using test_type = ostreambuf_iterator<wchar_t>;
+  static_assert(is_same<test_type::value_type, void>::value, "");
+#if __cplusplus <= 201703L
+  static_assert(is_same<test_type::difference_type, void>::value, "");
+#else
+  static_assert(is_same<test_type::difference_type, ptrdiff_t>::value, "");
+#endif
+  static_assert(is_same<test_type::pointer, void>::value, "");
+  static_assert(is_same<test_type::reference, void>::value, "");
+  static_assert(is_same<test_type::iterator_category, output_iterator_tag>::value, "");
+
+  static_assert(is_same<test_type::char_type, wchar_t>::value, "");
+  static_assert(is_same<test_type::traits_type, char_traits<wchar_t>>::value, "");
+  static_assert(is_same<test_type::ostream_type, wostream>::value, "");
+  static_assert(is_same<test_type::streambuf_type, wstreambuf>::value, "");
+}
+#endif
+#endif
diff --git a/libstdc++-v3/testsuite/24_iterators/output/concept.cc b/libstdc++-v3/testsuite/24_iterators/output/concept.cc
new file mode 100644 (file)
index 0000000..1b8c593
--- /dev/null
@@ -0,0 +1,121 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <iterator>
+
+using std::output_iterator;
+
+static_assert( output_iterator< int*, int > );
+static_assert( output_iterator< int*, const int > );
+static_assert( output_iterator< int*, long > );
+static_assert( output_iterator< void**, void* > );
+static_assert( output_iterator< void**, long* > );
+static_assert( ! output_iterator< const int*, int > );
+
+static_assert( ! output_iterator< int* const, int > );
+static_assert( ! output_iterator< const int* const, int > );
+static_assert( ! output_iterator< void** const, void* > );
+
+static_assert( ! output_iterator< void*, void > );
+static_assert( ! output_iterator< const void*, void > );
+static_assert( ! output_iterator< const void*, void* > );
+static_assert( ! output_iterator< volatile void*, void > );
+static_assert( ! output_iterator< volatile void*, void* > );
+
+static_assert( ! output_iterator< void(*)(), void(&)() > );
+static_assert( ! output_iterator< void(&)(), void(&)() > );
+static_assert( output_iterator< void(**)(), void(*)() > );
+static_assert( output_iterator< void(**)(), void(&)() > );
+
+struct A;
+static_assert( ! output_iterator< void(A::*)(), A* > );
+static_assert( ! output_iterator< void(A::*)(), void(A::*)() > );
+static_assert( ! output_iterator< int A::*, int > );
+static_assert( ! output_iterator< int A::*, int A::* > );
+
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <set>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::forward_list;
+using std::list;
+using std::set;
+using std::string;
+using std::string_view;
+using std::vector;
+
+struct B { };
+
+static_assert( output_iterator< array<int, 1>::iterator, int > );
+static_assert( output_iterator< array<B, 1>::iterator, B > );
+static_assert( ! output_iterator< array<int, 1>::const_iterator, int > );
+static_assert( ! output_iterator< array<B, 1>::const_iterator, B > );
+
+static_assert( output_iterator< deque<int>::iterator, int > );
+static_assert( output_iterator< deque<B>::iterator, B > );
+static_assert( ! output_iterator< deque<int>::const_iterator, int > );
+static_assert( ! output_iterator< deque<B>::const_iterator, B > );
+
+static_assert( output_iterator< forward_list<int>::iterator, int > );
+static_assert( output_iterator< forward_list<B>::iterator, B > );
+static_assert( ! output_iterator< forward_list<int>::const_iterator, int > );
+static_assert( ! output_iterator< forward_list<B>::const_iterator, B > );
+
+static_assert( output_iterator< list<int>::iterator, int > );
+static_assert( output_iterator< list<B>::iterator, B > );
+static_assert( ! output_iterator< list<int>::const_iterator, int > );
+static_assert( ! output_iterator< list<B>::const_iterator, B > );
+
+static_assert( ! output_iterator< set<int>::iterator, int > );
+static_assert( ! output_iterator< set<B>::iterator, B > );
+static_assert( ! output_iterator< set<int>::const_iterator, int > );
+static_assert( ! output_iterator< set<B>::const_iterator, B > );
+
+static_assert( output_iterator< string::iterator, char > );
+static_assert( output_iterator< string::iterator, int > );
+static_assert( ! output_iterator< string::const_iterator, char > );
+static_assert( ! output_iterator< string::const_iterator, int > );
+
+static_assert( ! output_iterator< string_view::iterator, char > );
+static_assert( ! output_iterator< string_view::iterator, int > );
+static_assert( ! output_iterator< string_view::const_iterator, char > );
+static_assert( ! output_iterator< string_view::const_iterator, int > );
+
+static_assert( output_iterator< vector<int>::iterator, int > );
+static_assert( output_iterator< vector<B>::iterator, B > );
+static_assert( ! output_iterator< vector<int>::const_iterator, int > );
+static_assert( ! output_iterator< vector<B>::const_iterator, B > );
+
+#include <streambuf>
+
+using std::istreambuf_iterator;
+using std::ostreambuf_iterator;
+
+static_assert( ! output_iterator< istreambuf_iterator<char>, char > );
+static_assert( ! output_iterator< istreambuf_iterator<char>, int > );
+static_assert( output_iterator< ostreambuf_iterator<char>, char > );
+static_assert( output_iterator< ostreambuf_iterator<char>, int > );
diff --git a/libstdc++-v3/testsuite/24_iterators/output/tag.cc b/libstdc++-v3/testsuite/24_iterators/output/tag.cc
new file mode 100644 (file)
index 0000000..515088e
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <iterator>
+
+using std::output_iterator_tag;
+using std::input_iterator_tag;
+using std::iterator_traits;
+
+static_assert( std::is_empty<output_iterator_tag>::value );
+static_assert( std::is_trivially_copy_constructible<output_iterator_tag>::value );
+
+static_assert( ! std::is_base_of<input_iterator_tag,
+                                output_iterator_tag>::value );
+static_assert( ! std::is_convertible<output_iterator_tag*,
+                                    input_iterator_tag*>::value );
diff --git a/libstdc++-v3/testsuite/24_iterators/random_access/concept.cc b/libstdc++-v3/testsuite/24_iterators/random_access/concept.cc
new file mode 100644 (file)
index 0000000..f513c57
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <iterator>
+
+using std::random_access_iterator;
+
+static_assert( random_access_iterator< int*        > );
+static_assert( random_access_iterator< const int* > );
+static_assert( random_access_iterator< void**      > );
+
+static_assert( ! random_access_iterator< int* const    > );
+static_assert( ! random_access_iterator< const int* const      > );
+static_assert( ! random_access_iterator< void** const  > );
+
+static_assert( ! random_access_iterator< void*   > );
+static_assert( ! random_access_iterator< const void*     > );
+static_assert( ! random_access_iterator< volatile void* > );
+
+static_assert( ! random_access_iterator< void(*)() > );
+static_assert( ! random_access_iterator< void(&)() > );
+
+struct A;
+static_assert( ! random_access_iterator< void(A::*)() > );
+static_assert( ! random_access_iterator< int A::*      > );
+
+#include <array>
+#include <deque>
+#include <list>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using std::array;
+using std::deque;
+using std::list;
+using std::string;
+using std::string_view;
+using std::vector;
+
+struct B { };
+
+static_assert( random_access_iterator< array<int, 1>::iterator     > );
+static_assert( random_access_iterator< array<B, 1>::const_iterator  > );
+
+static_assert( random_access_iterator< deque<int>::iterator    > );
+static_assert( random_access_iterator< deque<B>::const_iterator        > );
+
+static_assert( ! random_access_iterator< list<int>::iterator     > );
+static_assert( ! random_access_iterator< list<B>::const_iterator  > );
+
+static_assert( random_access_iterator< string::iterator                > );
+static_assert( random_access_iterator< string::const_iterator  > );
+
+static_assert( random_access_iterator< string_view::iterator       > );
+static_assert( random_access_iterator< string_view::const_iterator  > );
+
+static_assert( random_access_iterator< vector<int>::iterator     > );
+static_assert( random_access_iterator< vector<B>::const_iterator  > );
diff --git a/libstdc++-v3/testsuite/24_iterators/random_access/string_vector_iterators.cc b/libstdc++-v3/testsuite/24_iterators/random_access/string_vector_iterators.cc
new file mode 100644 (file)
index 0000000..c496254
--- /dev/null
@@ -0,0 +1,607 @@
+// 24.1.5 Random access iterators
+// 24.3.1 Iterator traits
+// (basic_string and vector implementations)
+//
+// Copyright (C) 1999-2019 Free Software Foundation, Inc.
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or 
+// (at your option) any later version.                             
+//                                                         
+// This program is distributed in the hope that it will be useful,   
+// but WITHOUT ANY WARRANTY; without even the implied warranty of    
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <string>
+#include <vector>
+#include <testsuite_hooks.h>
+
+int 
+string_stuff()
+{
+   int failures(0);
+
+   std::string s("abcde");
+
+   std::string::iterator i1(s.begin());
+   if (*i1 != 'a')
+      ++failures;
+
+   ++i1;
+   if (*i1 != 'b')
+      ++failures;
+
+   if (*i1++ != 'b')
+       ++failures;
+   if (*i1 != 'c')
+      ++failures;
+
+   ++ ++i1;
+   if (*i1 != 'e')
+      ++failures;
+
+   --i1;
+   if (*i1 != 'd')
+      ++failures;
+
+   if (*i1-- != 'd')
+      ++failures;
+   if (*i1 != 'c')
+      ++failures;
+
+   -- --i1;
+   if (*i1 != 'a')
+      ++failures;
+
+   std::string::iterator i2;
+   i2 = s.end();
+   std::iterator_traits<std::string::iterator>::difference_type d1;
+   d1 = i2 - i1;
+   if (d1 != 5)
+      ++failures;
+
+   std::iterator_traits<std::string::iterator>::value_type v1;
+   v1 = i1[0];
+   if (v1 != 'a')
+      ++failures;
+
+   std::iterator_traits<std::string::iterator>::reference r1(i1[0]);
+   if (r1 != 'a')
+      ++failures;
+   r1 = 'x';
+   if (r1 != 'x')
+      ++failures;
+   r1 = 'a';
+
+   if ((i1 != i2) != true)
+      ++failures;
+   if ((i1 == i2) != false)
+      ++failures;
+   if ((i1 <  i2) != true)
+      ++failures;
+   if ((i1 >  i2) != false)
+      ++failures;
+   if ((i1 <= i2) != true)
+      ++failures;
+   if ((i1 >= i2) != false)
+      ++failures;
+
+   std::string::iterator i3;
+   i3 = i1;
+   if ((i3 == i1) != true)
+      ++failures;
+
+   i3 += 5;
+   if ((i3 == i2) != true)
+      ++failures;
+
+   i3 -= 5;
+   if ((i3 == i1) != true)
+      ++failures;
+
+   if (i3 + 5 != i2)
+      ++failures;
+
+   if (5 + i3 != i2)
+      ++failures;
+
+   if (i2 - 5 != i3)
+      ++failures;
+
+   if (i1[0] != 'a')
+      ++failures;
+
+   i1[4] = 'x';
+   if (i2[-1] != 'x')
+      ++failures;
+   i1[4] = 'e';
+
+   i1[2] = 'x';
+   if (i2[-3] != 'x')
+      ++failures;
+   i1[2] = 'c';
+
+   std::string::const_iterator ci1(s.begin());
+   if (*ci1 != 'a')
+      ++failures;
+
+   ++ci1;
+   if (*ci1 != 'b')
+      ++failures;
+
+   if (*ci1++ != 'b')
+      ++failures;
+   if (*ci1 != 'c')
+      ++failures;
+
+   ++ ++ci1;
+   if (*ci1 != 'e')
+      ++failures;
+
+   --ci1;
+   if (*ci1 != 'd')
+      ++failures;
+
+   if (*ci1-- != 'd')
+      ++failures;
+   if (*ci1 != 'c')
+      ++failures;
+
+   -- --ci1;
+   if (*ci1 != 'a')
+      ++failures;
+
+   std::string::const_iterator ci2;
+   ci2 = s.end();
+   std::iterator_traits<std::string::const_iterator>::difference_type d2;
+   d2 = ci2 - ci1;
+   if (d2 != 5)
+     ++failures;
+
+   std::iterator_traits<std::string::const_iterator>::value_type v2;
+   v2 = ci1[0];
+   if (v2 != 'a')
+     ++failures;
+
+   std::iterator_traits<std::string::const_iterator>::reference r2(ci1[0]);
+   if (r2 != 'a')
+      ++failures;
+
+   if ((ci1 != ci2) != true)
+      ++failures;
+   if ((ci1 == ci2) != false)
+      ++failures;
+   if ((ci1 <  ci2) != true)
+      ++failures;
+   if ((ci1 >  ci2) != false)
+      ++failures;
+   if ((ci1 <= ci2) != true)
+      ++failures;
+   if ((ci1 >= ci2) != false)
+      ++failures;
+
+   std::string::const_iterator ci3;
+   ci3 = ci1;
+   if ((ci3 == ci1) != true)
+      ++failures;
+
+   ci3 += 5;
+   if ((ci3 == ci2) != true)
+      ++failures;
+
+   ci3 -= 5;
+   if ((ci3 == ci1) != true)
+      ++failures;
+
+   if (ci3 + 5 != ci2)
+      ++failures;
+
+   if (5 + ci3 != ci2)
+      ++failures;
+
+   if (ci2 - 5 != ci3)
+      ++failures;
+
+   if (ci1[2] != 'c')
+      ++failures;
+
+   if (ci2[-1] != 'e')
+      ++failures;
+
+   // iterator and const_iterator
+   std::string::const_iterator ci4(i1);
+   if ((ci4 == i1) != true)
+      ++failures;
+   if ((ci4 != i1) != false)
+      ++failures;
+   if ((ci4 < i1)  != false)
+     ++failures;
+   if ((ci4 > i1)  != false)
+     ++failures;
+   if ((ci4 <= i1) != true)
+     ++failures;
+   if ((ci4 >= i1) != true)
+     ++failures;
+   ci4 = i2;
+   if ((i2 == ci4) != true)
+     ++failures;
+   if ((i2 < ci4)  != false)
+     ++failures;
+   if ((i2 > ci4)  != false)
+     ++failures;
+   if ((i2 <= ci4) != true)
+     ++failures;
+   if ((i2 >= ci4) != true)
+     ++failures;
+
+   const std::string cs("ABCDE");
+   std::string::const_iterator ci5(cs.begin());
+   if (ci5[0] != 'A')
+      ++failures;
+
+   return failures;
+}
+
+int 
+vector_stuff()
+{
+   int failures(0);
+
+   std::vector<int> v;
+   v.push_back(int(1));
+   v.push_back(int(2));
+   v.push_back(int(3));
+   v.push_back(int(4));
+   v.push_back(int(5));
+
+   std::vector<int>::iterator i1(v.begin());
+   if (*i1 != 1)
+      ++failures;
+
+   ++i1;
+   if (*i1 != 2)
+      ++failures;
+
+   if (*i1++ != 2)
+      ++failures;
+   if (*i1 != 3)
+      ++failures;
+
+   ++ ++i1;
+   if (*i1 != 5)
+      ++failures;
+
+   --i1;
+   if (*i1 != 4)
+      ++failures;
+
+   if (*i1-- != 4)
+      ++failures;
+   if (*i1 != 3)
+      ++failures;
+
+   -- --i1;
+   if (*i1 != 1)
+      ++failures;
+
+   std::vector<int>::iterator i2;
+   i2 = v.end();
+   std::iterator_traits<std::vector<int>::iterator>::difference_type d1;
+   d1 = i2 - i1;
+   if (d1 != 5)
+      ++failures;
+
+   std::iterator_traits<std::vector<int>::iterator>::value_type v1;
+   v1 = i1[0];
+   if (v1 != 1)
+      ++failures;
+
+   std::iterator_traits<std::vector<int>::iterator>::reference r1(i1[0]);
+   if (r1 != 1)
+      ++failures;
+   r1 = 9;
+   if (r1 != 9)
+      ++failures;
+   r1 = 1;
+
+   if ((i1 != i2) != true)
+      ++failures;
+   if ((i1 == i2) != false)
+      ++failures;
+   if ((i1 <  i2) != true)
+      ++failures;
+   if ((i1 >  i2) != false)
+      ++failures;
+   if ((i1 <= i2) != true)
+      ++failures;
+   if ((i1 >= i2) != false)
+      ++failures;
+
+   std::vector<int>::iterator i3;
+   i3 = i1;
+   if ((i3 == i1) != true)
+      ++failures;
+
+   i3 += 5;
+   if ((i3 == i2) != true)
+      ++failures;
+
+   i3 -= 5;
+   if ((i3 == i1) != true)
+      ++failures;
+
+   if (i3 + 5 != i2)
+      ++failures;
+
+   if (5 + i3 != i2)
+      ++failures;
+
+   if (i2 - 5 != i3)
+      ++failures;
+
+   if (i1[0] != 1)
+      ++failures;
+
+   i1[4] = 9;
+   if (i2[-1] != 9)
+      ++failures;
+   i1[4] = 5;
+
+   i1[2] = 9;
+   if (i2[-3] != 9)
+      ++failures;
+   i1[2] = 3;
+
+   std::vector<int>::const_iterator ci1(v.begin());
+   if (*ci1 != 1)
+      ++failures;
+
+   ++ci1;
+   if (*ci1 != 2)
+      ++failures;
+
+   if (*ci1++ != 2)
+      ++failures;
+   if (*ci1 != 3)
+      ++failures;
+
+   ++ ++ci1;
+   if (*ci1 != 5)
+      ++failures;
+
+   --ci1;
+   if (*ci1 != 4)
+      ++failures;
+
+   if (*ci1-- != 4)
+      ++failures;
+   if (*ci1 != 3)
+      ++failures;
+
+   -- --ci1;
+   if (*ci1 != 1)
+      ++failures;
+
+   std::vector<int>::const_iterator ci2;
+   ci2 = v.end();
+   std::iterator_traits<std::vector<int>::const_iterator>::difference_type d2;
+   d2 = ci2 - ci1;
+   if (d2 != 5)
+      ++failures;
+
+   std::iterator_traits<std::vector<int>::const_iterator>::value_type v2;
+   v2 = ci1[0];
+   if (v2 != 1)
+      ++failures;
+
+   std::iterator_traits<std::vector<int>::const_iterator>::reference
+      r2(ci1[0]);
+   if (r2 != 1)
+      ++failures;
+
+   if ((ci1 != ci2) != true)
+      ++failures;
+   if ((ci1 == ci2) != false)
+      ++failures;
+   if ((ci1 <  ci2) != true)
+      ++failures;
+   if ((ci1 >  ci2) != false)
+      ++failures;
+   if ((ci1 <= ci2) != true)
+      ++failures;
+   if ((ci1 >= ci2) != false)
+      ++failures;
+
+   std::vector<int>::const_iterator ci3;
+   ci3 = ci1;
+   if ((ci3 == ci1) != true)
+      ++failures;
+
+   ci3 += 5;
+   if ((ci3 == ci2) != true)
+      ++failures;
+
+   ci3 -= 5;
+   if ((ci3 == ci1) != true)
+      ++failures;
+
+   if (ci3 + 5 != ci2)
+      ++failures;
+
+   if (5 + ci3 != ci2)
+      ++failures;
+
+   if (ci2 - 5 != ci3)
+      ++failures;
+
+   if (ci1[2] != 3)
+      ++failures;
+
+   if (ci2[-1] != 5)
+      ++failures;
+
+   // iterator to const_iterator
+   std::vector<int>::const_iterator ci4(i1);
+   if ((ci4 == i1) != true)
+      ++failures;
+   if ((ci4 != i1) != false)
+      ++failures;
+   if ((ci4 < i1)  != false)
+     ++failures;
+   if ((ci4 > i1)  != false)
+     ++failures;
+   if ((ci4 <= i1) != true)
+     ++failures;
+   if ((ci4 >= i1) != true)
+     ++failures;
+   ci4 = i2;
+   if ((i2 == ci4) != true)
+     ++failures;
+   if ((i2 < ci4)  != false)
+     ++failures;
+   if ((i2 > ci4)  != false)
+     ++failures;
+   if ((i2 <= ci4) != true)
+     ++failures;
+   if ((i2 >= ci4) != true)
+     ++failures;
+
+   const std::vector<int> cv(v);
+   std::vector<int>::const_iterator ci5(cv.begin());
+   if (ci5[0] != 1)
+      ++failures;
+
+   std::vector<std::string> vs;
+   vs.push_back(std::string("abc"));
+   std::vector<std::string>::iterator ivs(vs.begin());
+   if (ivs->c_str()[1] != 'b')
+      ++failures;
+
+   return failures;
+}
+
+int 
+reverse_stuff()
+{
+   int failures(0);
+
+   std::string s("abcde");
+
+   std::string::reverse_iterator ri(s.rbegin());
+   if (*ri != 'e')
+      ++failures;
+
+   std::iterator_traits<std::string::reverse_iterator>::difference_type d;
+   d = s.rend() - ri;
+   if (d != 5)
+      ++failures;
+
+   const std::string cs("abcde");
+   std::string::const_reverse_iterator cri(cs.rend());
+   if (cri - 5 != cs.rbegin())
+      ++failures;
+
+   return failures;
+}
+
+// the following should be compiler errors
+// flag runtime errors in case they slip through the compiler
+int 
+wrong_stuff()
+{
+   int failures(0);
+
+#ifdef ITER24_F1
+   extern void f(std::vector<std::string*>::iterator);
+   std::vector<std::string*> vs[2];
+   f(vs);                       // address of array is not an iterator
+   failures++;
+#endif
+
+#ifdef ITER24_F2
+   std::string s;
+   char *i = s.begin();         // begin() doesn't return a pointer
+   failures++;
+#endif
+
+#ifdef ITER24_F3
+   std::string::const_iterator ci;
+   std::string::iterator i;
+   if (i - ci)                  // remove const_ is a warning
+      i++;
+   // failures++;  only a warning
+#endif
+
+#ifdef ITER24_F4
+   std::vector<char>::iterator iv;
+   std::string::iterator is(iv);// vector<char> is not string
+   failures++;
+#endif
+
+#ifdef ITER24_F5
+   std::vector<char>::iterator iv;
+   std::string::iterator is;
+   if (iv == is)                // vector<char> is not string
+      ++iv;
+   failures++;
+#endif
+
+#ifdef ITER24_F6
+   std::vector<char>::const_iterator ci;
+   std::vector<char>::iterator i = ci;  // remove const_ is a warning
+   ++i;
+   // failures++; only a warning
+#endif
+
+#ifdef ITER24_F7
+   std::vector<int> v(1);
+   std::vector<int>::const_iterator ci(v.begin());
+   *ci = 1;                     // cannot assign through const_iterator
+   failures++;
+#endif
+
+#ifdef ITER24_F8
+   std::vector<const int> v(1);
+   std::vector<const int>::reference r(v.begin()[0]);
+   r = 1;                       // cannot assign through reference to const
+   failures++;
+#endif
+
+   return failures;
+}
+
+// libstdc++/6642
+int
+test6642()
+{
+   std::string s;
+   std::string::iterator it = s.begin();
+   std::string::const_iterator cit = s.begin();
+
+   return it - cit;
+}
+
+int
+main()
+{
+   int failures(0);
+
+   failures += string_stuff();
+
+   failures += vector_stuff();
+
+   failures += reverse_stuff();
+
+   failures += wrong_stuff();
+
+   failures += test6642();
+
+   VERIFY(failures == 0);
+   return 0;
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/random_access/tag.cc b/libstdc++-v3/testsuite/24_iterators/random_access/tag.cc
new file mode 100644 (file)
index 0000000..c2285fd
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <iterator>
+
+using std::random_access_iterator_tag;
+using std::bidirectional_iterator_tag;
+using std::iterator_traits;
+
+static_assert( std::is_empty<random_access_iterator_tag>::value );
+static_assert( std::is_trivially_copy_constructible<random_access_iterator_tag>::value );
+
+static_assert( std::is_base_of<bidirectional_iterator_tag,
+                              random_access_iterator_tag>::value );
+static_assert( std::is_convertible<random_access_iterator_tag*,
+                                  bidirectional_iterator_tag*>::value );
+
+static_assert( std::is_same<iterator_traits<int*>::iterator_category,
+                           random_access_iterator_tag>::value );
diff --git a/libstdc++-v3/testsuite/24_iterators/random_access_iterator/26020.cc b/libstdc++-v3/testsuite/24_iterators/random_access_iterator/26020.cc
deleted file mode 100644 (file)
index ec23443..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2006-2019 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// 24.3.4 Iterator operations
-
-#include <iterator>
-#include <list>
-#include <testsuite_hooks.h>
-
-//libstdc++/26020
-void test01()
-{
-  using namespace std;
-
-  list<int> ll;
-  ll.push_back(1);
-
-  list<int>::iterator it(ll.begin());
-
-  advance(it, 0.5);
-
-  VERIFY( it == ll.begin() );
-}
-
-int main()
-{
-  test01();
-  return 0;
-}
diff --git a/libstdc++-v3/testsuite/24_iterators/random_access_iterator/string_vector_iterators.cc b/libstdc++-v3/testsuite/24_iterators/random_access_iterator/string_vector_iterators.cc
deleted file mode 100644 (file)
index c496254..0000000
+++ /dev/null
@@ -1,607 +0,0 @@
-// 24.1.5 Random access iterators
-// 24.3.1 Iterator traits
-// (basic_string and vector implementations)
-//
-// Copyright (C) 1999-2019 Free Software Foundation, Inc.
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or 
-// (at your option) any later version.                             
-//                                                         
-// This program is distributed in the hope that it will be useful,   
-// but WITHOUT ANY WARRANTY; without even the implied warranty of    
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-
-#include <string>
-#include <vector>
-#include <testsuite_hooks.h>
-
-int 
-string_stuff()
-{
-   int failures(0);
-
-   std::string s("abcde");
-
-   std::string::iterator i1(s.begin());
-   if (*i1 != 'a')
-      ++failures;
-
-   ++i1;
-   if (*i1 != 'b')
-      ++failures;
-
-   if (*i1++ != 'b')
-       ++failures;
-   if (*i1 != 'c')
-      ++failures;
-
-   ++ ++i1;
-   if (*i1 != 'e')
-      ++failures;
-
-   --i1;
-   if (*i1 != 'd')
-      ++failures;
-
-   if (*i1-- != 'd')
-      ++failures;
-   if (*i1 != 'c')
-      ++failures;
-
-   -- --i1;
-   if (*i1 != 'a')
-      ++failures;
-
-   std::string::iterator i2;
-   i2 = s.end();
-   std::iterator_traits<std::string::iterator>::difference_type d1;
-   d1 = i2 - i1;
-   if (d1 != 5)
-      ++failures;
-
-   std::iterator_traits<std::string::iterator>::value_type v1;
-   v1 = i1[0];
-   if (v1 != 'a')
-      ++failures;
-
-   std::iterator_traits<std::string::iterator>::reference r1(i1[0]);
-   if (r1 != 'a')
-      ++failures;
-   r1 = 'x';
-   if (r1 != 'x')
-      ++failures;
-   r1 = 'a';
-
-   if ((i1 != i2) != true)
-      ++failures;
-   if ((i1 == i2) != false)
-      ++failures;
-   if ((i1 <  i2) != true)
-      ++failures;
-   if ((i1 >  i2) != false)
-      ++failures;
-   if ((i1 <= i2) != true)
-      ++failures;
-   if ((i1 >= i2) != false)
-      ++failures;
-
-   std::string::iterator i3;
-   i3 = i1;
-   if ((i3 == i1) != true)
-      ++failures;
-
-   i3 += 5;
-   if ((i3 == i2) != true)
-      ++failures;
-
-   i3 -= 5;
-   if ((i3 == i1) != true)
-      ++failures;
-
-   if (i3 + 5 != i2)
-      ++failures;
-
-   if (5 + i3 != i2)
-      ++failures;
-
-   if (i2 - 5 != i3)
-      ++failures;
-
-   if (i1[0] != 'a')
-      ++failures;
-
-   i1[4] = 'x';
-   if (i2[-1] != 'x')
-      ++failures;
-   i1[4] = 'e';
-
-   i1[2] = 'x';
-   if (i2[-3] != 'x')
-      ++failures;
-   i1[2] = 'c';
-
-   std::string::const_iterator ci1(s.begin());
-   if (*ci1 != 'a')
-      ++failures;
-
-   ++ci1;
-   if (*ci1 != 'b')
-      ++failures;
-
-   if (*ci1++ != 'b')
-      ++failures;
-   if (*ci1 != 'c')
-      ++failures;
-
-   ++ ++ci1;
-   if (*ci1 != 'e')
-      ++failures;
-
-   --ci1;
-   if (*ci1 != 'd')
-      ++failures;
-
-   if (*ci1-- != 'd')
-      ++failures;
-   if (*ci1 != 'c')
-      ++failures;
-
-   -- --ci1;
-   if (*ci1 != 'a')
-      ++failures;
-
-   std::string::const_iterator ci2;
-   ci2 = s.end();
-   std::iterator_traits<std::string::const_iterator>::difference_type d2;
-   d2 = ci2 - ci1;
-   if (d2 != 5)
-     ++failures;
-
-   std::iterator_traits<std::string::const_iterator>::value_type v2;
-   v2 = ci1[0];
-   if (v2 != 'a')
-     ++failures;
-
-   std::iterator_traits<std::string::const_iterator>::reference r2(ci1[0]);
-   if (r2 != 'a')
-      ++failures;
-
-   if ((ci1 != ci2) != true)
-      ++failures;
-   if ((ci1 == ci2) != false)
-      ++failures;
-   if ((ci1 <  ci2) != true)
-      ++failures;
-   if ((ci1 >  ci2) != false)
-      ++failures;
-   if ((ci1 <= ci2) != true)
-      ++failures;
-   if ((ci1 >= ci2) != false)
-      ++failures;
-
-   std::string::const_iterator ci3;
-   ci3 = ci1;
-   if ((ci3 == ci1) != true)
-      ++failures;
-
-   ci3 += 5;
-   if ((ci3 == ci2) != true)
-      ++failures;
-
-   ci3 -= 5;
-   if ((ci3 == ci1) != true)
-      ++failures;
-
-   if (ci3 + 5 != ci2)
-      ++failures;
-
-   if (5 + ci3 != ci2)
-      ++failures;
-
-   if (ci2 - 5 != ci3)
-      ++failures;
-
-   if (ci1[2] != 'c')
-      ++failures;
-
-   if (ci2[-1] != 'e')
-      ++failures;
-
-   // iterator and const_iterator
-   std::string::const_iterator ci4(i1);
-   if ((ci4 == i1) != true)
-      ++failures;
-   if ((ci4 != i1) != false)
-      ++failures;
-   if ((ci4 < i1)  != false)
-     ++failures;
-   if ((ci4 > i1)  != false)
-     ++failures;
-   if ((ci4 <= i1) != true)
-     ++failures;
-   if ((ci4 >= i1) != true)
-     ++failures;
-   ci4 = i2;
-   if ((i2 == ci4) != true)
-     ++failures;
-   if ((i2 < ci4)  != false)
-     ++failures;
-   if ((i2 > ci4)  != false)
-     ++failures;
-   if ((i2 <= ci4) != true)
-     ++failures;
-   if ((i2 >= ci4) != true)
-     ++failures;
-
-   const std::string cs("ABCDE");
-   std::string::const_iterator ci5(cs.begin());
-   if (ci5[0] != 'A')
-      ++failures;
-
-   return failures;
-}
-
-int 
-vector_stuff()
-{
-   int failures(0);
-
-   std::vector<int> v;
-   v.push_back(int(1));
-   v.push_back(int(2));
-   v.push_back(int(3));
-   v.push_back(int(4));
-   v.push_back(int(5));
-
-   std::vector<int>::iterator i1(v.begin());
-   if (*i1 != 1)
-      ++failures;
-
-   ++i1;
-   if (*i1 != 2)
-      ++failures;
-
-   if (*i1++ != 2)
-      ++failures;
-   if (*i1 != 3)
-      ++failures;
-
-   ++ ++i1;
-   if (*i1 != 5)
-      ++failures;
-
-   --i1;
-   if (*i1 != 4)
-      ++failures;
-
-   if (*i1-- != 4)
-      ++failures;
-   if (*i1 != 3)
-      ++failures;
-
-   -- --i1;
-   if (*i1 != 1)
-      ++failures;
-
-   std::vector<int>::iterator i2;
-   i2 = v.end();
-   std::iterator_traits<std::vector<int>::iterator>::difference_type d1;
-   d1 = i2 - i1;
-   if (d1 != 5)
-      ++failures;
-
-   std::iterator_traits<std::vector<int>::iterator>::value_type v1;
-   v1 = i1[0];
-   if (v1 != 1)
-      ++failures;
-
-   std::iterator_traits<std::vector<int>::iterator>::reference r1(i1[0]);
-   if (r1 != 1)
-      ++failures;
-   r1 = 9;
-   if (r1 != 9)
-      ++failures;
-   r1 = 1;
-
-   if ((i1 != i2) != true)
-      ++failures;
-   if ((i1 == i2) != false)
-      ++failures;
-   if ((i1 <  i2) != true)
-      ++failures;
-   if ((i1 >  i2) != false)
-      ++failures;
-   if ((i1 <= i2) != true)
-      ++failures;
-   if ((i1 >= i2) != false)
-      ++failures;
-
-   std::vector<int>::iterator i3;
-   i3 = i1;
-   if ((i3 == i1) != true)
-      ++failures;
-
-   i3 += 5;
-   if ((i3 == i2) != true)
-      ++failures;
-
-   i3 -= 5;
-   if ((i3 == i1) != true)
-      ++failures;
-
-   if (i3 + 5 != i2)
-      ++failures;
-
-   if (5 + i3 != i2)
-      ++failures;
-
-   if (i2 - 5 != i3)
-      ++failures;
-
-   if (i1[0] != 1)
-      ++failures;
-
-   i1[4] = 9;
-   if (i2[-1] != 9)
-      ++failures;
-   i1[4] = 5;
-
-   i1[2] = 9;
-   if (i2[-3] != 9)
-      ++failures;
-   i1[2] = 3;
-
-   std::vector<int>::const_iterator ci1(v.begin());
-   if (*ci1 != 1)
-      ++failures;
-
-   ++ci1;
-   if (*ci1 != 2)
-      ++failures;
-
-   if (*ci1++ != 2)
-      ++failures;
-   if (*ci1 != 3)
-      ++failures;
-
-   ++ ++ci1;
-   if (*ci1 != 5)
-      ++failures;
-
-   --ci1;
-   if (*ci1 != 4)
-      ++failures;
-
-   if (*ci1-- != 4)
-      ++failures;
-   if (*ci1 != 3)
-      ++failures;
-
-   -- --ci1;
-   if (*ci1 != 1)
-      ++failures;
-
-   std::vector<int>::const_iterator ci2;
-   ci2 = v.end();
-   std::iterator_traits<std::vector<int>::const_iterator>::difference_type d2;
-   d2 = ci2 - ci1;
-   if (d2 != 5)
-      ++failures;
-
-   std::iterator_traits<std::vector<int>::const_iterator>::value_type v2;
-   v2 = ci1[0];
-   if (v2 != 1)
-      ++failures;
-
-   std::iterator_traits<std::vector<int>::const_iterator>::reference
-      r2(ci1[0]);
-   if (r2 != 1)
-      ++failures;
-
-   if ((ci1 != ci2) != true)
-      ++failures;
-   if ((ci1 == ci2) != false)
-      ++failures;
-   if ((ci1 <  ci2) != true)
-      ++failures;
-   if ((ci1 >  ci2) != false)
-      ++failures;
-   if ((ci1 <= ci2) != true)
-      ++failures;
-   if ((ci1 >= ci2) != false)
-      ++failures;
-
-   std::vector<int>::const_iterator ci3;
-   ci3 = ci1;
-   if ((ci3 == ci1) != true)
-      ++failures;
-
-   ci3 += 5;
-   if ((ci3 == ci2) != true)
-      ++failures;
-
-   ci3 -= 5;
-   if ((ci3 == ci1) != true)
-      ++failures;
-
-   if (ci3 + 5 != ci2)
-      ++failures;
-
-   if (5 + ci3 != ci2)
-      ++failures;
-
-   if (ci2 - 5 != ci3)
-      ++failures;
-
-   if (ci1[2] != 3)
-      ++failures;
-
-   if (ci2[-1] != 5)
-      ++failures;
-
-   // iterator to const_iterator
-   std::vector<int>::const_iterator ci4(i1);
-   if ((ci4 == i1) != true)
-      ++failures;
-   if ((ci4 != i1) != false)
-      ++failures;
-   if ((ci4 < i1)  != false)
-     ++failures;
-   if ((ci4 > i1)  != false)
-     ++failures;
-   if ((ci4 <= i1) != true)
-     ++failures;
-   if ((ci4 >= i1) != true)
-     ++failures;
-   ci4 = i2;
-   if ((i2 == ci4) != true)
-     ++failures;
-   if ((i2 < ci4)  != false)
-     ++failures;
-   if ((i2 > ci4)  != false)
-     ++failures;
-   if ((i2 <= ci4) != true)
-     ++failures;
-   if ((i2 >= ci4) != true)
-     ++failures;
-
-   const std::vector<int> cv(v);
-   std::vector<int>::const_iterator ci5(cv.begin());
-   if (ci5[0] != 1)
-      ++failures;
-
-   std::vector<std::string> vs;
-   vs.push_back(std::string("abc"));
-   std::vector<std::string>::iterator ivs(vs.begin());
-   if (ivs->c_str()[1] != 'b')
-      ++failures;
-
-   return failures;
-}
-
-int 
-reverse_stuff()
-{
-   int failures(0);
-
-   std::string s("abcde");
-
-   std::string::reverse_iterator ri(s.rbegin());
-   if (*ri != 'e')
-      ++failures;
-
-   std::iterator_traits<std::string::reverse_iterator>::difference_type d;
-   d = s.rend() - ri;
-   if (d != 5)
-      ++failures;
-
-   const std::string cs("abcde");
-   std::string::const_reverse_iterator cri(cs.rend());
-   if (cri - 5 != cs.rbegin())
-      ++failures;
-
-   return failures;
-}
-
-// the following should be compiler errors
-// flag runtime errors in case they slip through the compiler
-int 
-wrong_stuff()
-{
-   int failures(0);
-
-#ifdef ITER24_F1
-   extern void f(std::vector<std::string*>::iterator);
-   std::vector<std::string*> vs[2];
-   f(vs);                       // address of array is not an iterator
-   failures++;
-#endif
-
-#ifdef ITER24_F2
-   std::string s;
-   char *i = s.begin();         // begin() doesn't return a pointer
-   failures++;
-#endif
-
-#ifdef ITER24_F3
-   std::string::const_iterator ci;
-   std::string::iterator i;
-   if (i - ci)                  // remove const_ is a warning
-      i++;
-   // failures++;  only a warning
-#endif
-
-#ifdef ITER24_F4
-   std::vector<char>::iterator iv;
-   std::string::iterator is(iv);// vector<char> is not string
-   failures++;
-#endif
-
-#ifdef ITER24_F5
-   std::vector<char>::iterator iv;
-   std::string::iterator is;
-   if (iv == is)                // vector<char> is not string
-      ++iv;
-   failures++;
-#endif
-
-#ifdef ITER24_F6
-   std::vector<char>::const_iterator ci;
-   std::vector<char>::iterator i = ci;  // remove const_ is a warning
-   ++i;
-   // failures++; only a warning
-#endif
-
-#ifdef ITER24_F7
-   std::vector<int> v(1);
-   std::vector<int>::const_iterator ci(v.begin());
-   *ci = 1;                     // cannot assign through const_iterator
-   failures++;
-#endif
-
-#ifdef ITER24_F8
-   std::vector<const int> v(1);
-   std::vector<const int>::reference r(v.begin()[0]);
-   r = 1;                       // cannot assign through reference to const
-   failures++;
-#endif
-
-   return failures;
-}
-
-// libstdc++/6642
-int
-test6642()
-{
-   std::string s;
-   std::string::iterator it = s.begin();
-   std::string::const_iterator cit = s.begin();
-
-   return it - cit;
-}
-
-int
-main()
-{
-   int failures(0);
-
-   failures += string_stuff();
-
-   failures += vector_stuff();
-
-   failures += reverse_stuff();
-
-   failures += wrong_stuff();
-
-   failures += test6642();
-
-   VERIFY(failures == 0);
-   return 0;
-}
diff --git a/libstdc++-v3/testsuite/24_iterators/range_operations/advance_debug_neg.cc b/libstdc++-v3/testsuite/24_iterators/range_operations/advance_debug_neg.cc
new file mode 100644 (file)
index 0000000..6a21da3
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a -D_GLIBCXX_DEBUG" }
+// { dg-do compile { xfail c++2a } }
+
+#include <iterator>
+#include <testsuite_iterators.h>
+
+void
+test01()
+{
+  int a[2] = { };
+  __gnu_test::test_container<int, __gnu_test::forward_iterator_wrapper> c(a);
+  auto iter = c.begin();
+  std::ranges::advance(iter, -1);
+}