Date
2016-11-12.20:15:11
Message id
8537

Content

[ 2016-10 Telecon ]

Ville's wording has been implemented in libstdc++ and libc++. Move this to Tentatively Ready and 2757 to Tentatively Resolved

Previous resolution [SUPERSEDED]:

This wording is relative to N4606.

  1. In [basic.string] modify the synopsis for basic_string as follows:

    namespace std {
      template<class charT, class traits = char_traits<charT>,
        class Allocator = allocator<charT>>
      class basic_string {
      public:
        […]
        template<class T>
        basic_string& append(basic_string_view<charT, traits> svconst T& t,
                             size_type pos, size_type n = npos);
        […]
        template<class T>
        basic_string& assign(basic_string_view<charT, traits> svconst T& t,
                             size_type pos, size_type n = npos);
        […]
        template<class T>
        basic_string& insert(size_type pos1, basic_string_view<charT, traits> svconst T& t,
                             size_type pos2, size_type n = npos);
        […]
        template<class T>
        basic_string& replace(size_type pos1, size_type n1,
                              basic_string_view<charT, traits> svconst T& t,
                              size_type pos2, size_type n2 = npos);
        […]
        template<class T>
        int compare(size_type pos1, size_type n1,
                    basic_string_view<charT, traits> svconst T& t,
                    size_type pos2, size_type n2 = npos) const;
        […]
      };
    }
    
  2. In [string.append], modify basic_string_view overload as follows:

    template<class T>
    basic_string& append(basic_string_view<charT, traits> svconst T& t,
                         size_type pos, size_type n = npos);
    

    -7- Throws: out_of_range if pos > sv.size().

    -8- Effects: Creates a variable, sv, as if by basic_string_view<charT, traits> sv = t. Determines the effective length rlen of the string to append as the smaller of n and sv.size() - pos and calls append(sv.data() + pos, rlen).

    -?- Remarks: This function shall not participate in overload resolution unless is_convertible_v<const T&, basic_string_view<charT, traits>> is true.

    -9- Returns: *this.

  3. In [string.assign], modify basic_string_view overload as follows:

    template<class T>
    basic_string& assign(basic_string_view<charT, traits> svconst T& t,
                         size_type pos, size_type n = npos);
    

    -9- Throws: out_of_range if pos > sv.size().

    -10- Effects: Creates a variable, sv, as if by basic_string_view<charT, traits> sv = t. Determines the effective length rlen of the string to assign as the smaller of n and sv.size() - pos and calls assign(sv.data() + pos, rlen).

    -?- Remarks: This function shall not participate in overload resolution unless is_convertible_v<const T&, basic_string_view<charT, traits>> is true.

    -11- Returns: *this.

  4. In [string.insert], modify basic_string_view overload as follows:

    template<class T>
    basic_string& insert(size_type pos1, basic_string_view<charT, traits> svconst T& t,
                         size_type pos2, size_type n = npos);
    

    -6- Throws: out_of_range if pos1 > size() or pos2 > sv.size().

    -7- Effects: Creates a variable, sv, as if by basic_string_view<charT, traits> sv = t. Determines the effective length rlen of the string to assign as the smaller of n and sv.size() - pos2 and calls insert(pos1, sv.data() + pos2, rlen).

    -?- Remarks: This function shall not participate in overload resolution unless is_convertible_v<const T&, basic_string_view<charT, traits>> is true.

    -8- Returns: *this.

  5. In [string.replace], modify basic_string_view overload as follows:

    template<class T>
    basic_string& replace(size_type pos1, size_type n1, 
                         basic_string_view<charT, traits> svconst T& t,
                         size_type pos2, size_type n2 = npos);
    

    -6- Throws: out_of_range if pos1 > size() or pos2 > sv.size().

    -7- Effects: Creates a variable, sv, as if by basic_string_view<charT, traits> sv = t. Determines the effective length rlen of the string to be inserted as the smaller of n2 and sv.size() - pos2 and calls replace(pos1, n1, sv.data() + pos2, rlen).

    -?- Remarks: This function shall not participate in overload resolution unless is_convertible_v<const T&, basic_string_view<charT, traits>> is true.

    -8- Returns: *this.

  6. In [string.compare], modify basic_string_view overload as follows:

    template<class T>
    int compare(size_type pos1, size_type n1,
                basic_string_view<charT, traits> svconst T& t,
                size_type pos2, size_type n2 = npos) const;
    

    -4- Effects: Equivalent to:

    {
      basic_string_view<charT, traits> sv = t;
      return basic_string_view<charT, traits>(this.data(), pos1, n1).compare(sv, pos2, n2);
    }
    

    -?- Remarks: This function shall not participate in overload resolution unless is_convertible_v<const T&, basic_string_view<charT, traits>> is true.