Title
basic_string_view::copy should use char_traits::copy
Status
c++17
Section
[string.view.ops][string.copy]
Submitter
Billy Robert O'Neal III

Created on 2016-09-27.00:00:00 last changed 89 months ago

Messages

Date: 2016-10-08.04:58:13

Proposed resolution:

This wording is relative to N4606.

  1. Change [string.copy] as indicated:

    size_type copy(charT* s, size_type n, size_type pos = 0) const;
    

    -?- Let rlen be the smaller of n and size() - pos.

    -2- Throws: out_of_range if pos > size().

    -?- Requires: [s, s + rlen) is a valid range.

    -3- Effects: Determines the effective length rlen of the string to copy as the smaller of n and size() - pos. s shall designate an array of at least rlen elements.Equivalent to: traits::copy(s, data() + pos, rlen). [Note: This does not terminate s with a null object. — end note]

    The function then replaces the string designated by s with a string of length rlen whose elements are a copy of the string controlled by *this beginning at position pos.

    The function does not append a null object to the string designated by s.

    -4- Returns: rlen.

  2. Change [string.view.ops] as indicated:

    size_type copy(charT* s, size_type n, size_type pos = 0) const;
    

    -1- Let rlen be the smaller of n and size() - pos.

    -2- Throws: out_of_range if pos > size().

    -3- Requires: [s, s + rlen) is a valid range.

    -4- Effects: Equivalent to: copy_n(begin() + pos, rlen, s)traits::copy(s, data() + pos, rlen)

    -5- Returns: rlen.

    -6- Complexity: 𝒪(rlen).

Date: 2017-02-02.00:41:18

[ Issues processing Telecon 2016-10-7 ]

P0; set to Tentatively Ready

Removed "Note to project editor", since the issue there has been fixed in the current draft.

Date: 2016-09-27.00:00:00

basic_string_view::copy is inconsistent with basic_string::copy, in that the former uses copy_n and the latter uses traits::copy. We should have this handling be consistent.

Moreover, the basic_string::copy description is excessively roundabout due to copy-on-write era wording.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-10-08 04:58:13adminsetmessages: + msg8546
2016-10-08 04:58:13adminsetstatus: new -> ready
2016-10-03 16:56:10adminsetmessages: + msg8533
2016-09-27 00:00:00admincreate