diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst --- a/libcxx/docs/UsingLibcxx.rst +++ b/libcxx/docs/UsingLibcxx.rst @@ -345,3 +345,19 @@ * ``identity::operator()`` * ``to_integer`` * ``to_underlying`` + + +Lowered requirements of ``OutputIterator`` in ```` +------------------------------------------------------------- + +In C++20 the Standard changed the iterator requirements, but the requirements +for the iterators in ```` remained unchanged. As an extension +several algorithms in ```` 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`` diff --git a/libcxx/include/__algorithm/fill_n.h b/libcxx/include/__algorithm/fill_n.h --- a/libcxx/include/__algorithm/fill_n.h +++ b/libcxx/include/__algorithm/fill_n.h @@ -11,6 +11,7 @@ #include <__config> #include <__iterator/iterator_traits.h> +#include <__utility/move.h> #include #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 diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp @@ -148,12 +148,22 @@ int main(int, char**) { test_char >(); +#if _LIBCPP_VERSION + // The iterator statisfies the output_iterator concept but not the + // Cpp17OutputIterator allowing this in is a libc++ extension. + test_char >(); +#endif test_char >(); test_char >(); test_char >(); test_char(); test_int >(); +#if _LIBCPP_VERSION + // The iterator statisfies the output_iterator concept but not the + // Cpp17OutputIterator allowing this in is a libc++ extension. + test_int >(); +#endif test_int >(); test_int >(); test_int >();