Title
ranges::uninitialized_copy_n, ranges::uninitialized_move_n, and ranges::destroy_n should use std::move
Status
c++23
Section
[uninitialized.copy][uninitialized.move] [specialized.destroy]
Submitter
Hewill Kang

Created on 2022-07-28.00:00:00 last changed 13 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to N4910.

  1. Modify [uninitialized.copy] as indicated:

    namespace ranges {
      template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
        requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
        uninitialized_copy_n_result<I, O>
          uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
    }
    

    -9- Preconditions: [ofirst, olast) does not overlap with ifirst + [0, n) .

    -10- Effects: Equivalent to:

    auto t = uninitialized_copy(counted_iterator(std::move(ifirst), n),
                                default_sentinel, ofirst, olast);
    return {std::move(t.in).base(), t.out};
    
  2. Modify [uninitialized.move] as indicated:

    namespace ranges {
      template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
        requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
        uninitialized_move_n_result<I, O>
          uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
    }
    

    -8- Preconditions: [ofirst, olast) does not overlap with ifirst + [0, n) .

    -9- Effects: Equivalent to:

    auto t = uninitialized_move(counted_iterator(std::move(ifirst), n),
                                default_sentinel, ofirst, olast);
    return {std::move(t.in).base(), t.out};
    
  3. Modify [specialized.destroy] as indicated:

    namespace ranges {
      template<nothrow-input-iterator I>
        requires destructible<iter_value_t<I>>
        constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
    }
    

    -5- Effects: Equivalent to:

    return destroy(counted_iterator(std::move(first), n), default_sentinel).base();
    
Date: 2022-11-12.00:00:00

[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]

Date: 2022-08-15.00:00:00

[ 2022-08-23; Reflector poll ]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

Date: 2022-07-28.00:00:00

Currently, ranges::uninitialized_copy_n has the following equivalent Effects:

auto t = uninitialized_copy(counted_iterator(ifirst, n),
                            default_sentinel, ofirst, olast);
return {std::move(t.in).base(), t.out};

Given that ifirst is just an input_iterator which is not guaranteed to be copyable, we should move it into counted_iterator. The same goes for ranges::uninitialized_move_n and ranges::destroy_n.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13060
2022-11-17 00:42:33adminsetstatus: voting -> wp
2022-11-08 03:46:49adminsetstatus: ready -> voting
2022-08-23 15:24:34adminsetmessages: + msg12695
2022-08-23 15:24:34adminsetstatus: new -> ready
2022-07-30 14:11:15adminsetmessages: + msg12666
2022-07-28 00:00:00admincreate