Created on 2016-01-05.00:00:00 last changed 90 months ago
Proposed resolution:
This wording is relative to N4567.
Modify [string.assign] p.1 as indicated:
basic_string& assign(const basic_string& str);-1- Effects: Equivalent to *this = str
-2- Returns: *this.assign(str, 0, npos).
[ 2016-02, Issues Telecon ]
P0; move to Tentatively Ready.
In issue 2063, we changed the Effects of basic_string::assign(basic_string&&) to match the behavior of basic_string::operator=(basic_string&&), making them consistent.
We did not consider basic_string::assign(const basic_string&), and its Effects differ from operator=(const basic_string&). Given the following definition:typedef std::basic_string<char, std::char_traits<char>, MyAllocator<char>> MyString; MyAllocator<char> alloc1, alloc2; MyString string1("Alloc1", alloc1); MyString string2(alloc2);
the following bits of code are not equivalent:
string2 = string1; // (a) calls operator=(const MyString&) string2.assign(string1); // (b) calls MyString::assign(const MyString&)
What is the allocator for string2 after each of these calls?
If MyAllocator<char>::propagate_on_container_copy_assignment is true, then it should be alloc2, otherwise it should be alloc1.
alloc2
[string.assign]/1 says that (b) is equivalent to assign(string1, 0, npos), which eventually calls assign(str.data() + pos, rlen). No allocator transfer there.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2016-03-07 04:11:48 | admin | set | status: ready -> wp |
2016-02-07 20:24:45 | admin | set | messages: + msg7968 |
2016-02-07 20:24:45 | admin | set | status: new -> ready |
2016-01-15 20:48:15 | admin | set | messages: + msg7676 |
2016-01-05 00:00:00 | admin | create |