Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofResolved status.

2757.std::string{}.insert(3, "ABCDE", 0, 1) is ambiguous

Section: 27.4.3.7.4[string.insert]Status:ResolvedSubmitter: Marshall ClowOpened: 2016-07-30Last modified: 2020-09-06

Priority:1

View all otherissues in [string.insert].

View all issues withResolved status.

Discussion:

Before C++17, we had the following signature tostd::basic_string:

basic_string&  insert(size_type pos1, const basic_string& str, size_type pos2, size_type n = npos);

Unlike most of the other member functions onstd::basic_string, there were not correspondingversions that take acharT* or(charT *, size).

Inp0254r2, we added:

basic_string&  insert(size_type pos1, basic_string_view<charT, traits> sv, size_type pos2, size_type n = npos);

which made the code above ambiguous. There are two conversions from "const charT*", one tobasic_string, and the other tobasic_string_view, and they're both equally good (in the view of the compiler).

This ambiguity also occurs with the calls

assign(const basic_string& str,             size_type pos, size_type n = npos);assign(basic_string_view<charT, traits> sv, size_type pos, size_type n = npos);

but I will file a separate issue (2758(i)) for that.

A solution is to addeven more overloads toinsert, to make it match all the other memberfunctions ofbasic_string, which come in fours (string,pointer,pointer + size,string_view).

[2016-08-03, Chicago, Robert Douglas provides wording]

Previous resolution [SUPERSEDED]:

This wording is relative to N4606.

  1. In 27.4.3[basic.string] modify the synopsis forbasic_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& insert(size_type pos1,basic_string_view<charT, traits>T sv,                         size_type pos2, size_type n = npos);    […]  };}
  2. In 27.4.3.7.4[string.insert], modifybasic_string_view overload as follows:

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

    […]

    -?-Remarks: This function shall not participate in overload resolution unlessis_same_v<T, basic_string_view<charT, traits>> istrue.

[2016-08-04, Chicago, Robert Douglas comments]

For the sake of simplicity, the previous wording suggestion has been merged into the proposed wordingof LWG2758(i).

[08-2016, Chicago]

Fri PM: Move to Tentatively Ready (along with2758(i)).

[2016-09-09 Issues Resolution Telecon]

Since2758(i) has been moved back to Open, move this one, too

[2016-10 Telecon]

Ville's wording for2758(i) has been implemented in libstdc++ and libc++. Move2758(i) to Tentatively Ready and this one to Tentatively Resolved

Proposed resolution:

This issue is resolved by the proposed wording for LWG2758(i).


[8]ページ先頭

©2009-2026 Movatter.jp