On 29/04/19 13:13 +0100, Jonathan Wakely wrote:
The standard only requires that _Size can be converted to an integral
type, not that it can be used for arithmetic. Add a new set of
__size_to_integer helper functions to do the conversion (which will be
ambiguous if there is no one conversion that is better than any others).
Also add tests for DR 426 which requires these algorithms and search_n
to handle negative values of n.
PR libstdc++/87982
* include/bits/stl_algo.h (generate_n): Convert _Size parameter to
an integral type.
* include/bits/stl_algobase.h (__size_to_integer): New overloaded
functions to convert a value to an integral type.
(__fill_n_a, __fill_n_a): Assert that __n is already an integral
type.
(fill_n): Convert _Size parameter to an integral type.
* testsuite/25_algorithms/fill_n/dr426.cc: New test.
* testsuite/25_algorithms/generate_n/87982.cc: New test.
* testsuite/25_algorithms/generate_n/dr426.cc: New test.
diff --git a/libstdc++-v3/include/bits/stl_algo.h
b/libstdc++-v3/include/bits/stl_algo.h
index cb870c41dc1..ae9bb8f14b0 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -4433,9 +4433,11 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
* Performs the assignment @c *i = @p __gen() for each @c i in the range
* @p [__first,__first+__n).
*
- * _GLIBCXX_RESOLVE_LIB_DEFECTS
- * DR 865. More algorithms that throw away information
+ * If @p __n is negative, the function does nothing.
I've committed a further tweak to this comment.
commit b6de22fdcbebfedb691290a91e4a0aa66a351819
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Mon Apr 29 14:30:11 2019 +0100
Adjust doxygen comment for std::generate_n
* include/bits/stl_algo.h (generate_n): Adjust doxygen comment.
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index ae9bb8f14b0..b50c642f0e6 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -4433,7 +4433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
* Performs the assignment @c *i = @p __gen() for each @c i in the range
* @p [__first,__first+__n).
*
- * If @p __n is negative, the function does nothing.
+ * If @p __n is negative, the function does nothing and returns @p __first.
*/
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 865. More algorithms that throw away information