cplusplus / nbballot

Handling of NB comments in response to ballots
14 stars 4 forks source link

GB308 25 [algorithms] Change half-range algorithms to taking full ranges #304

Closed wg21bot closed 4 years ago

wg21bot commented 4 years ago

All half ranges should be fully rangified It seems odd that we're not offering full ranges for the ranges that we write to. We can potentially eliminate a class of error by requiring all ranges have bounds, and implementations can optimise for the unreachable_sentinel_t case. This is already the case for the uninitialised memory algorithms.

Proposed change: Redesign all ranges algorithms with half-ranges so that they're fully bounded. Example:

// Current
template<input_iterator I, sentinel_for<I> S, weakly_incrementable O>
  requires indirectly_copyable<I, O>
  constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result);
template<input_range R, weakly_incrementable O>
  requires indirectly_copyable, O>
  constexpr ranges::copy_result<safe_iterator_t<R>, O> ranges::copy(R&& r, O result);
// Proposed
template<input_iterator I, sentinel_for<I> S1,
         input_or_output_iterator O, sentinel_for<O> S2>
  requires indirectly_copyable<I, O>
  constexpr ranges::copy_result<I, O> ranges::copy(I first, S1 last, O result, S2 result_last);
template<input_range R, range O>
  requires indirectly_copyable<iterator_t, iterator_t<O>>
  constexpr ranges::copy_result<safe_iterator_t, safe_iterator_t<O>> ranges::copy(R&& r, O&& result);
tituswinters commented 4 years ago

LEWG in Belfast: Rejected. No consensus for change.