Unwrapping output iterators in range algorithms by CaseyCarter · Pull Request #5015 · microsoft/STL (original) (raw)
This completes the last bits of the iterator unwrapping design for Ranges algorithms.
Detailed commit-wise description:
- Expand
_Idl_distance
design for Ranges- Add
_Distance_unbounded
to represent the distance between an iterator andunreachable_sentinel
. _Idl_distance
takes iterator/sentinel pairs in C++20 mode.- Add
_RANGES _Idl_distance(range)
, equivalent to_STD _Idl_distance
but forsized_range
instead ofsized_sentinel_for
. - Support integer-class counts in
_Get_unwrapped_n
.
- Add
- Simplify
ranges::destroy_n
. Now that_Get_unwrapped_n
supports integer-class counts, we don't need to apply_Algorithm_int_t
to_Count
. - Update operations on
_Idl_distance
s- Refactor
_Idl_dist_add
:
* Useif constexpr
dispatch instead of overloading.
*_Distance_unbounded
plus anything is_Distance_unbounded
. - Implement
_Idl_dist_min
to compute the smaller of two_Idl_distance
s.
- Refactor
- Rename Range algorithm output iterator parameters from
_Result
to_Output
. This changes our convention. I think_Output
is more appropriate than_Result
for this purpose given that most algorithms produce more results than just the output sequence. This also makes_Result
unambiguously available to refer to the return value of the algorithm which is consistent with our use of_UResult
for intermediate unwrapped results. - Unwrap outputs in
ranges::copy
- Unwrap outputs in
ranges::copy_backward
- Unwrap outputs in
ranges::copy_if
- Unwrap outputs in
ranges::copy_n
- Unwrap outputs in
ranges::merge
- Unwrap outputs in
ranges::move
- Unwrap outputs in
ranges::move_backward
- Unwrap outputs in
ranges::replace_copy
- Unwrap outputs in
ranges::replace_copy_if
- Unwrap outputs in
ranges::reverse_copy
- Unwrap outputs in
ranges::rotate_copy
- Unwrap outputs in
ranges::sample
- Unwrap outputs in
ranges::transform
(The warning suppression is necessary to prevent the static analyzer diagnosing the computation of_Min_size_determinable
as redundant when_Rng1
and_Rng2
are the same type.)
Fixes #893.