Title
The memory algorithms should support move-only input iterators introduced by P1207
Status
c++20
Section
[uninitialized.copy][uninitialized.move]
Submitter
Corentin Jabot

Created on 2019-11-12.00:00:00 last changed 45 months ago

Messages

Date: 2020-02-14.11:24:43

Proposed resolution:

This wording is relative to N4842.

  1. Modify [uninitialized.copy] as indicated:

    namespace ranges {
      template<input_iterator I, sentinel_for<I> S1,
               no-throw-forward-iterator O, no-throw-sentinel<O> S2>
          requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
        uninitialized_copy_result<I, O>
          uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
      template<input_range IR, no-throw-forward-range OR>
          requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
        uninitialized_copy_result<safe_iterator_t<IR>, safe_iterator_t<OR>>
          uninitialized_copy(IR&& in_range, OR&& out_range);
    }
    

    -4- Preconditions: [ofirst, olast) shall not overlap with [ifirst, ilast).

    -5- Effects: Equivalent to:

    for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst) {
      ::new (voidify(*ofirst)) remove_reference_t<iter_reference_t<O>>(*ifirst);
    }
    return {std::move(ifirst), ofirst};
    

    […]
    namespace ranges {
      template<input_iterator I, no-throw-forward-iterator O, no-throw-sentinel<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) shall not overlap with [ifirst, n).

    -10- Effects: Equivalent to:

    auto t = uninitialized_copy(counted_iterator(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, sentinel_for<I> S1,
               no-throw-forward-iterator O, no-throw-sentinel<O> S2>
          requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
        uninitialized_move_result<I, O>
          uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
      template<input_range IR, no-throw-forward-range OR>
          requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
        uninitialized_move_result<safe_iterator_t<IR>, safe_iterator_t<OR>>
          uninitialized_move(IR&& in_range, OR&& out_range);
    }
    

    -3- Preconditions: [ofirst, olast) shall not overlap with [ifirst, ilast).

    -4- Effects: Equivalent to:

    for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst) {
      ::new (voidify(*ofirst)) 
        remove_reference_t<iter_reference_t<O>>(ranges::iter_move(*ifirst));
    }
    return {std::move(ifirst), ofirst};
    

    […]
    namespace ranges {
      template<input_iterator I, no-throw-forward-iterator O, no-throw-sentinel<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) shall not overlap with [ifirst, n).

    -9- Effects: Equivalent to:

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

Date: 2020-02-14.11:24:43

[ 2020-02 Status to Immediate on Friday morning in Prague. ]

Date: 2020-01-05.16:13:01

[ 2020-01 Priority set to 2 after review on the reflector. ]

Date: 2019-11-12.00:00:00

P1207 introduced move-only input iterators but did not modify the specialized memory algorithms to support them.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 11:24:43adminsetmessages: + msg11119
2020-02-14 11:24:43adminsetstatus: new -> immediate
2020-01-05 16:13:01adminsetmessages: + msg10907
2019-12-11 19:14:09adminsetmessages: + msg10878
2019-11-12 00:00:00admincreate