[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos-adaptors)] libstdc++: Apply the move_iterator changes described in P1207R4

Patrick Palka ppalka@gcc.gnu.org
Tue Feb 4 02:32:00 GMT 2020


https://gcc.gnu.org/g:c6c2a67f4839952653d7aceb24e09503b0eb15e6

commit c6c2a67f4839952653d7aceb24e09503b0eb15e6
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jan 22 16:51:19 2020 -0500

    libstdc++: Apply the move_iterator changes described in P1207R4
    
    These changes are needed for some of the tests in the constrained algorithm
    patch, because they use move_iterator with an uncopyable output_iterator.  The
    other changes described in the paper are already applied, it seems.
    
    libstdc++-v3/ChangeLog:
    
    	* include/bits/stl_iterator.h (move_iterator::move_iterator): Move the
    	iterator when initializing _M_current.
    	(move_iterator::base): Split into two overloads differing in
    	ref-qualifiers as in P1207R4.

Diff:
---
 libstdc++-v3/include/bits/stl_iterator.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 784d200..1a288a5 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1166,7 +1166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       explicit _GLIBCXX17_CONSTEXPR
       move_iterator(iterator_type __i)
-      : _M_current(__i) { }
+      : _M_current(std::move(__i)) { }
 
       template<typename _Iter>
 	_GLIBCXX17_CONSTEXPR
@@ -1174,9 +1174,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	: _M_current(__i.base()) { }
 
       _GLIBCXX17_CONSTEXPR iterator_type
-      base() const
+      base() const &
+#if __cplusplus > 201703L && __cpp_lib_concepts
+	requires copy_constructible<iterator_type>
+#endif
       { return _M_current; }
 
+      _GLIBCXX17_CONSTEXPR iterator_type
+      base() &&
+      { return std::move(_M_current); }
+
       _GLIBCXX17_CONSTEXPR reference
       operator*() const
       { return static_cast<reference>(*_M_current); }



More information about the Libstdc++-cvs mailing list