std::iterator considered as deprecated since C++17 and shouldn't be in use.
This patch marks std::iterator as deprecated using deprecated
attribute, and replace its usages with the required member types
inside each class.

libstdc++-v3/include/bits/ChangeLog:
        stl_iterator_base_types.h: Add deprecated attribute to std::iterator.
        stl_bvector.h: Replace std::iterator usage with required member types.
        stl_iterator.h: Replace std::iterator usage with required member types.
        stl_raw_storage_iter.h: Replace std::iterator usage with
required member types.
        stream_iterator.h: Replace std::iterator usage with required
member types.
        streambuf_iterator.h: Replace std::iterator usage with
required member types.

libstdc++-v3/include/ext/ChangeLog:
        rope: Replace std::iterator usage with required member types.

-----------------------------------------------------------------------------------------------

diff --git a/libstdc++-v3/include/bits/stl_bvector.h
b/libstdc++-v3/include/bits/stl_bvector.h
index d6f5435..e92b895 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -140,8 +140,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #endif

   struct _Bit_iterator_base
+#if __cplusplus < 201703L
   : public std::iterator<std::random_access_iterator_tag, bool>
+#endif
   {
+#if __cplusplus >= 201703L // C++17
+    // BEGIN: Iterator base types
+    /// One of the @link iterator_tags tag types@endlink.
+    using iterator_category = std::random_access_iterator_tag;
+    /// The type "pointed to" by the iterator.
+    using value_type           = bool;
+    /// Distance between iterators is represented as this type.
+    using difference_type      = ptrdiff_t;
+    /// This type represents a pointer-to-value_type.
+    using pointer                      = bool*;
+    /// This type represents a reference-to-value_type.
+    using reference            = bool&;
+    // END: Iterator base types
+#endif
+
     _Bit_type * _M_p;
     unsigned int _M_offset;

diff --git a/libstdc++-v3/include/bits/stl_iterator.h
b/libstdc++-v3/include/bits/stl_iterator.h
index 2259f7c..13d5dbb 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -124,12 +124,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template<typename _Iterator>
     class reverse_iterator
+#if __cplusplus < 201703L
     : public iterator<typename iterator_traits<_Iterator>::iterator_category,
                      typename iterator_traits<_Iterator>::value_type,
                      typename iterator_traits<_Iterator>::difference_type,
                      typename iterator_traits<_Iterator>::pointer,
                       typename iterator_traits<_Iterator>::reference>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    protected:
+      typedef iterator_traits<_Iterator> __traits_type;
+
+    public:
+      // BEGIN: Iterator base types
+#if !__cpp_lib_concepts
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = typename __traits_type::iterator_category;
+#endif
+      /// The type "pointed to" by the iterator.
+      using value_type                         = typename
__traits_type::value_type;
+      /// Distance between iterators is represented as this type.
+      using difference_type    = typename __traits_type::difference_type;
+      /// This type represents a pointer-to-value_type.
+      using pointer                    = typename __traits_type::pointer;
+      /// This type represents a reference-to-value_type.
+      using reference                  = typename __traits_type::reference;
+      // END: Iterator base types
+       private:
+#endif
       template<typename _Iter>
        friend class reverse_iterator;

@@ -143,14 +166,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

     protected:
       _Iterator current;
-
+#if __cplusplus < 201703L
       typedef iterator_traits<_Iterator>               __traits_type;
-
+#endif
     public:
       typedef _Iterator                                        iterator_type;
-      typedef typename __traits_type::difference_type  difference_type;
+#if __cplusplus < 201703L
+         typedef typename __traits_type::difference_type       difference_type;
       typedef typename __traits_type::pointer          pointer;
       typedef typename __traits_type::reference                reference;
+#endif

 #if __cplusplus > 201703L && __cpp_lib_concepts
       using iterator_concept
@@ -625,8 +650,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template<typename _Container>
     class back_insert_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type                         = void;
+#if __cplusplus <= 201703L
+      /// Distance between iterators is represented as this type.
+      using difference_type    = void;
+#endif
+      /// This type represents a pointer-to-value_type.
+      using pointer                            = void;
+      /// This type represents a reference-to-value_type.
+      using reference                  = void;
+      // END: Iterator base types
+#endif
+
     protected:
       _Container* container;

@@ -728,8 +773,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template<typename _Container>
     class front_insert_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type                         = void;
+#if __cplusplus <= 201703L
+      /// Distance between iterators is represented as this type.
+      using difference_type    = void;
+#endif
+      /// This type represents a pointer-to-value_type.
+      using pointer                    = void;
+      /// This type represents a reference-to-value_type.
+      using reference                  = void;
+      // END: Iterator base types
+#endif
+
     protected:
       _Container* container;

@@ -835,8 +900,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template<typename _Container>
     class insert_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type                         = void;
+#if __cplusplus <= 201703L || ! defined __cpp_lib_concepts
+      /// Distance between iterators is represented as this type.
+      using difference_type    = void;
+#endif
+      /// This type represents a pointer-to-value_type.
+      using pointer                    = void;
+      /// This type represents a reference-to-value_type.
+      using reference                  = void;
+      // END: Iterator base types
+#endif
+
 #if __cplusplus > 201703L && defined __cpp_lib_concepts
       using _Iter = std::__detail::__range_iter_t<_Container>;

diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h
b/libstdc++-v3/include/bits/stl_iterator_base_types.h
index aa02af5..a959dec 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_types.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h
@@ -124,7 +124,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
            typename _Pointer = _Tp*, typename _Reference = _Tp&>
+#if __cplusplus >= 201703L // C++17
+       struct [[deprecated]] iterator
+#else
     struct iterator
+#endif
     {
       /// One of the @link iterator_tags tag types@endlink.
       typedef _Category  iterator_category;
diff --git a/libstdc++-v3/include/bits/stl_raw_storage_iter.h
b/libstdc++-v3/include/bits/stl_raw_storage_iter.h
index df7a5f9..8eb8835 100644
--- a/libstdc++-v3/include/bits/stl_raw_storage_iter.h
+++ b/libstdc++-v3/include/bits/stl_raw_storage_iter.h
@@ -66,8 +66,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   */
   template <class _OutputIterator, class _Tp>
     class raw_storage_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type                         = void;
+      /// Distance between iterators is represented as this type.
+      using difference_type    = void;
+      /// This type represents a pointer-to-value_type.
+      using pointer                    = void;
+      /// This type represents a reference-to-value_type.
+      using reference                  = void;
+      // END: Iterator base types
+#endif
     protected:
       _OutputIterator _M_iter;

diff --git a/libstdc++-v3/include/bits/stream_iterator.h
b/libstdc++-v3/include/bits/stream_iterator.h
index bd5ba2a..a264cb8 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -47,8 +47,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp, typename _CharT = char,
            typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t>
     class istream_iterator
+#if __cplusplus < 201703L
     : public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category = input_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type = _Tp;
+      /// Distance between iterators is represented as this type.
+      using difference_type = _Dist;
+      /// This type represents a pointer-to-value_type.
+      using pointer = const _Tp*;
+      /// This type represents a reference-to-value_type.
+      using reference = const _Tp&;
+      // END: Iterator base types
+#endif
+
     public:
       typedef _CharT                         char_type;
       typedef _Traits                        traits_type;
@@ -174,8 +192,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp, typename _CharT = char,
            typename _Traits = char_traits<_CharT> >
     class ostream_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type = void;
+#if __cplusplus == 201703L
+      /// Distance between iterators is represented as this type.
+      using difference_type = void;
+#endif
+      /// This type represents a pointer-to-value_type.
+      using pointer = void;
+      /// This type represents a reference-to-value_type.
+      using reference = void;
+      // END: Iterator base types
+#endif
+
     public:
       //@{
       /// Public typedef
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h
b/libstdc++-v3/include/bits/streambuf_iterator.h
index 184c82c..eda5648 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -48,9 +48,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// Provides input iterator semantics for streambufs.
   template<typename _CharT, typename _Traits>
     class istreambuf_iterator
+#if __cplusplus < 201703L
     : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type,
                      _CharT*, _CharT>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category = input_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type = _CharT;
+      /// Distance between iterators is represented as this type.
+      using difference_type = typename _Traits::off_type;
+#if __cplusplus == 201703L
+      /// This type represents a pointer-to-value_type.
+      using pointer = _CharT*;
+#endif
+      /// This type represents a reference-to-value_type.
+      using reference = _CharT;
+      // END: Iterator base types
+#endif
+
     public:
       // Types:
       //@{
@@ -236,8 +256,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// Provides output iterator semantics for streambufs.
   template<typename _CharT, typename _Traits>
     class ostreambuf_iterator
+#if __cplusplus < 201703L
     : public iterator<output_iterator_tag, void, void, void, void>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category  = output_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type                         = void;
+#if __cplusplus == 201703L
+      /// Distance between iterators is represented as this type.
+      using difference_type    = void;
+#endif
+      /// This type represents a pointer-to-value_type.
+      using pointer                    = void;
+      /// This type represents a reference-to-value_type.
+      using reference                  = void;
+      // END: Iterator base types
+#endif
+
     public:
       // Types:
       //@{
diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope
index fb7bdb0..86a0549 100644
--- a/libstdc++-v3/include/ext/rope
+++ b/libstdc++-v3/include/ext/rope
@@ -173,10 +173,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

   template<class _Sequence, std::size_t _Buf_sz = 100>
     class sequence_buffer
+#if __cplusplus < 201703L
     : public std::iterator<std::output_iterator_tag, void, void, void, void>
+#endif
     {
     public:
       typedef typename _Sequence::value_type value_type;
+#if __cplusplus >= 201703L // C++17
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category = std::output_iterator_tag;
+      /// Distance between iterators is represented as this type.
+      using difference_type = void;
+      /// This type represents a pointer-to-value_type.
+      using pointer = void;
+      /// This type represents a reference-to-value_type.
+      using reference = void;
+      // END: Iterator base types
+#endif
     protected:
       _Sequence* _M_prefix;
       value_type _M_buffer[_Buf_sz];
@@ -1054,8 +1068,27 @@ protected:

   template<class _CharT, class _Alloc>
     class _Rope_iterator_base
+#if __cplusplus < 201703L
     : public std::iterator<std::random_access_iterator_tag, _CharT>
+#endif
     {
+#if __cplusplus >= 201703L // C++17
+    public:
+      // BEGIN: Iterator base types
+      /// One of the @link iterator_tags tag types@endlink.
+      using iterator_category = std::random_access_iterator_tag;
+      /// The type "pointed to" by the iterator.
+      using value_type = _CharT;
+      /// Distance between iterators is represented as this type.
+      using difference_type = ptrdiff_t;
+      /// This type represents a pointer-to-value_type.
+      using pointer = _CharT*;
+      /// This type represents a reference-to-value_type.
+      using reference = _CharT&;
+      // END: Iterator base types
+      private:
+#endif
+
       friend class rope<_CharT, _Alloc>;
     public:
       typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround

Reply via email to