[libcxx-commits] [PATCH] D122074: [libc++] Allow an output_iterator in fill.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 19 11:14:55 PDT 2022
Mordante updated this revision to Diff 416712.
Mordante added a comment.
Fix CI.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122074/new/
https://reviews.llvm.org/D122074
Files:
libcxx/docs/UsingLibcxx.rst
libcxx/include/__algorithm/fill_n.h
libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
@@ -148,12 +148,22 @@
int main(int, char**)
{
test_char<cpp17_output_iterator<char*> >();
+#if _LIBCPP_VERSION
+ // The iterator statisfies the output_iterator concept but not the
+ // Cpp17OutputIterator allowing this in <algorithm> is a libc++ extension.
+ test_char<cpp20_output_iterator<char*> >();
+#endif
test_char<forward_iterator<char*> >();
test_char<bidirectional_iterator<char*> >();
test_char<random_access_iterator<char*> >();
test_char<char*>();
test_int<cpp17_output_iterator<int*> >();
+#if _LIBCPP_VERSION
+ // The iterator statisfies the output_iterator concept but not the
+ // Cpp17OutputIterator allowing this in <algorithm> is a libc++ extension.
+ test_int<cpp20_output_iterator<int*> >();
+#endif
test_int<forward_iterator<int*> >();
test_int<bidirectional_iterator<int*> >();
test_int<random_access_iterator<int*> >();
Index: libcxx/include/__algorithm/fill_n.h
===================================================================
--- libcxx/include/__algorithm/fill_n.h
+++ libcxx/include/__algorithm/fill_n.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -34,7 +35,7 @@
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
- return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
+ return std::__fill_n(std::move(__first), std::__convert_to_integral(__n), __value_);
}
_LIBCPP_END_NAMESPACE_STD
Index: libcxx/docs/UsingLibcxx.rst
===================================================================
--- libcxx/docs/UsingLibcxx.rst
+++ libcxx/docs/UsingLibcxx.rst
@@ -345,3 +345,19 @@
* ``identity::operator()``
* ``to_integer``
* ``to_underlying``
+
+
+Lowered requirements of ``OutputIterator`` in ``<algorithm>``
+-------------------------------------------------------------
+
+In C++20 the Standard changed the iterator requirements, but the requirements
+for the iterators in ``<algorithm>`` remained unchanged. As an extension
+several algorithms in ``<algorithm>`` now only require the ``OutputIterator``
+to satisfy the ``output_iterator`` concept instead of the
+``Cpp17OutputIterator`` requirement. From a user's perspective the main change
+is that a movable non-copyable ``OutputIterator`` is now allowed in all
+language versions.
+
+Theses changes have been applied to the following algorithms:
+
+* ``fill_n``
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122074.416712.patch
Type: text/x-patch
Size: 2830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220319/9239f76a/attachment.bin>
More information about the libcxx-commits
mailing list