Created on 2016-07-30.00:00:00 last changed 99 months ago
Proposed resolution:
This issue is resolved by the proposed wording for LWG 2758.
[ 2016-09-09 Issues Resolution Telecon ]
Since 2758 has been moved back to Open, move this one, too
[ 08-2016, Chicago ]
Fri PM: Move to Tentatively Ready (along with 2758).
[ 2016-08-04, Chicago, Robert Douglas comments ]
For the sake of simplicity, the previous wording suggestion has been merged into the proposed wording of LWG 2758.
[ 2016-08-03, Chicago, Robert Douglas provides wording ]
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
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& insert(size_type pos1,basic_string_view<charT, traits>T sv, size_type pos2, size_type n = npos); […] }; }In [string.insert], modify basic_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 unless is_same_v<T, basic_string_view<charT, traits>> is true.
Before C++17, we had the following signature to std::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 on std::basic_string, there were not corresponding versions that take a charT* or (charT *, size).
In p0254r2, 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 to basic_string, and the other to basic_string_view, and they're both equally good (in the view of the compiler).
This ambiguity also occurs with the callsassign(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) for that.
A solution is to add even more overloads to insert, to make it match all the other member functions of basic_string, which come in fours (string, pointer, pointer + size, string_view).History | |||
---|---|---|---|
Date | User | Action | Args |
2016-10-10 20:46:47 | admin | set | messages: + msg8552 |
2016-10-10 20:46:47 | admin | set | status: open -> resolved |
2016-09-12 04:46:33 | admin | set | messages: + msg8518 |
2016-09-12 04:46:33 | admin | set | status: ready -> open |
2016-08-06 21:12:20 | admin | set | messages: + msg8449 |
2016-08-06 21:12:20 | admin | set | status: new -> ready |
2016-08-05 16:56:25 | admin | set | messages: + msg8425 |
2016-08-03 22:01:08 | admin | set | messages: + msg8378 |
2016-07-30 16:06:49 | admin | set | messages: + msg8270 |
2016-07-30 00:00:00 | admin | create |