]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Rearrange std::move_iterator helpers in stl_iterator.h
authorJonathan Wakely <jwakely@redhat.com>
Thu, 10 Oct 2024 21:47:46 +0000 (22:47 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 11 Oct 2024 16:04:56 +0000 (17:04 +0100)
The __niter_base(move_iterator<I>) overload and __is_move_iterator trait
were originally immediately after the definition of move_iterator. The
addition of C++20 features after move_iterator meant that those helpers
were no longer anywhere near move_iterator.

This change puts them back where they used to be, before all the new
C++20 additions.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (__niter_base(move_iterator<I>))
(__is_move_iterator, __miter_base, _GLIBCXX_MAKE_MOVE_ITERATOR)
(_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR): Move earlier in the
file.

libstdc++-v3/include/bits/stl_iterator.h

index 20c0319f3a7ace9a9fa27e3e3f3d960599d0893f..28a600c81cb25190efbe26b11ae08001a5c94b06 100644 (file)
@@ -1349,9 +1349,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value)
     { return __it.base(); }
 
-#if __cplusplus >= 201103L
-
-#if __cplusplus <= 201703L
+#if __cplusplus >= 201103L && __cplusplus <= 201703L
   // Need to overload __to_address because the pointer_traits primary template
   // will deduce element_type of __normal_iterator<T*, C> as T* rather than T.
   template<typename _Iterator, typename _Container>
@@ -1362,6 +1360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return std::__to_address(__it.base()); }
 #endif
 
+#if __cplusplus >= 201103L
   /**
    * @addtogroup iterators
    * @{
@@ -1821,6 +1820,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __make_move_if_noexcept_iterator(_Tp* __i)
     { return _ReturnType(__i); }
 
+  template<typename _Iterator>
+    _GLIBCXX20_CONSTEXPR
+    auto
+    __niter_base(move_iterator<_Iterator> __it)
+    -> decltype(make_move_iterator(__niter_base(__it.base())))
+    { return make_move_iterator(__niter_base(__it.base())); }
+
+  template<typename _Iterator>
+    struct __is_move_iterator<move_iterator<_Iterator> >
+    {
+      enum { __value = 1 };
+      typedef __true_type __type;
+    };
+
+  template<typename _Iterator>
+    _GLIBCXX20_CONSTEXPR
+    auto
+    __miter_base(move_iterator<_Iterator> __it)
+    -> decltype(__miter_base(__it.base()))
+    { return __miter_base(__it.base()); }
+
+#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
+#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
+  std::__make_move_if_noexcept_iterator(_Iter)
+#else
+#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
+#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
+#endif // C++11
+
 #if __cplusplus > 201703L && __glibcxx_concepts
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 3736.  move_iterator missing disable_sized_sentinel_for specialization
@@ -2957,35 +2985,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @} group iterators
 
-  template<typename _Iterator>
-    _GLIBCXX20_CONSTEXPR
-    auto
-    __niter_base(move_iterator<_Iterator> __it)
-    -> decltype(make_move_iterator(__niter_base(__it.base())))
-    { return make_move_iterator(__niter_base(__it.base())); }
-
-  template<typename _Iterator>
-    struct __is_move_iterator<move_iterator<_Iterator> >
-    {
-      enum { __value = 1 };
-      typedef __true_type __type;
-    };
-
-  template<typename _Iterator>
-    _GLIBCXX20_CONSTEXPR
-    auto
-    __miter_base(move_iterator<_Iterator> __it)
-    -> decltype(__miter_base(__it.base()))
-    { return __miter_base(__it.base()); }
-
-#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
-#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \
-  std::__make_move_if_noexcept_iterator(_Iter)
-#else
-#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
-#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter)
-#endif // C++11
-
 #if __cpp_deduction_guides >= 201606
   // These helper traits are used for deduction guides
   // of associative containers.