Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwrapping output iterators in range algorithms #5015

Merged
merged 19 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify ranges::destroy_n
Now that `_Get_unwrapped_n` supports integer-class counts, we don't need to apply `_Algorithm_int_t` to `_Count`.
CaseyCarter committed Oct 14, 2024
commit 1d3f3c99e1e22d1adbcf639f1043f3a3769e5994
3 changes: 1 addition & 2 deletions stl/inc/memory
Original file line number Diff line number Diff line change
@@ -645,8 +645,7 @@ namespace ranges {
template <_No_throw_input_iterator _It>
requires destructible<iter_value_t<_It>>
_STATIC_CALL_OPERATOR constexpr _It operator()(
_It _First, const iter_difference_t<_It> _Count_raw) _CONST_CALL_OPERATOR noexcept {
_Algorithm_int_t<iter_difference_t<_It>> _Count = _Count_raw;
_It _First, iter_difference_t<_It> _Count) _CONST_CALL_OPERATOR noexcept {
if (_Count <= 0) {
return _First;
}
4 changes: 3 additions & 1 deletion stl/inc/xutility
Original file line number Diff line number Diff line change
@@ -3591,7 +3591,9 @@ namespace ranges {

template <range _Rng>
_NODISCARD constexpr auto _Idl_distance(_Rng& _Range) {
// returns _STD _Idl_distance<iterator_t<_Rng>>(begin(_Range), end(_Range))
// Returns the length of _Range if it is finite and can be determined in O(1), or
// an indicator that the length is infinite, or
// an indicator that the length cannot be determined in O(1).
if constexpr (sized_range<_Rng>) {
return _RANGES distance(_Range);
} else if constexpr (same_as<sentinel_t<_Rng>, unreachable_sentinel_t>) {