[PATCH] libstdc++: P0769R2 Add shift to <algorithm>

Jonathan Wakely jwakely@redhat.com
Mon Mar 2 12:20:00 GMT 2020


On 02/03/20 10:03 +0100, Stephan Bergmann wrote:
>On 21/02/2020 20:29, Patrick Palka wrote:
>>diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h
>>index 7de1072abf0..c36afc6e19b 100644
>>--- a/libstdc++-v3/include/bits/ranges_algo.h
>>+++ b/libstdc++-v3/include/bits/ranges_algo.h
>>@@ -3683,6 +3683,54 @@ namespace ranges
>>    inline constexpr __prev_permutation_fn prev_permutation{};
>>  } // namespace ranges
>>+
>>+  template<class ForwardIterator>
>>+    constexpr ForwardIterator
>>+    shift_left(ForwardIterator __first, ForwardIterator __last,
>>+	       typename iterator_traits<ForwardIterator>::difference_type __n)
>>+    {
>>+      __glibcxx_assert(__n >= 0);
>>+      if (__n == 0)
>>+	return __last;
>>+
>>+      auto __mid = ranges::next(__first, __n, __last);
>>+      if (__mid == __last)
>>+	return __first;
>>+      return std::move(std::move(__mid), std::move(__last), std::move(__first));
>>+    }
>>+
>>+  template<class ForwardIterator>
>>+    constexpr ForwardIterator
>>+    shift_right(ForwardIterator __first, ForwardIterator __last,
>>+		typename iterator_traits<ForwardIterator>::difference_type __n)
>>+    {
>>+      __glibcxx_assert(__n >= 0);
>>+      if (__n == 0)
>>+	return __first;
>>+
>>+      using _Cat = iterator_traits<ForwardIterator>::iterator_category;
>
>^ FYI, the above line causes recent Clang 10 trunk with -std=c++20 to 
>fail due to a "missing" typedef

Thanks, fixed by this patch, committed to master now.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 887 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20200302/7fcc8c1d/attachment.bin>


More information about the Libstdc++ mailing list