Title
Who is definitive: operator= or assign?
Status
nad
Section
[string.cons][string.assign][re.regex.assign]
Submitter
Marshall Clow

Created on 2016-01-05.00:00:00 last changed 99 months ago

Messages

Date: 2016-02-10.00:48:28

[ 2016-02 ]

Changed basic_regex to match string as an editorial change. Closing as NAD

Date: 2016-02-07.20:24:45

[ 2016-02, Issues Telecon ]

Marshall to see if this can be dealt with editorially. Change Regex so that assign is in terms of op=

Date: 2016-01-16.20:54:10

There are two "containers" in the standard who have member functions named assign that take parameters of the type of the container (as opposed to iterators, pointers, what have you).

In string's case, we define assign in terms of operator=. In regex's case, we define operator= in terms of assign.

We should pick a style and use use it.

In [string.cons], we have:

basic_string& operator=(const basic_string& str);

-17- Effects: If *this and str are not the same object, modifies *this as shown in Table 70.

-18- If *this and str are the same object, the member has no effect.

-19- Returns: *this

basic_string& operator=(basic_string&& str)
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || 
           allocator_traits<Allocator>::is_always_equal::value);

-20- Effects: Move assigns as a sequence container (23.2), except that iterators, pointers and references may be invalidated.

-21- Returns: *this

In [string.assign], we have:

basic_string& assign(const basic_string& str);

-1- Effects: Equivalent to assign(str, 0, npos).

-2- Returns: *this.

basic_string& assign(basic_string&& str) 
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
           allocator_traits<Allocator>::is_always_equal::value);

-2- Effects: Equivalent to *this = std::move(str).

-3- Returns: *this.

Marshall says: There is another issue 2579 here, to change /1 to be similar to /2.

In [re.regex.assign], we have:

basic_regex& operator=(const basic_regex& e);

-1- Effects: returns assign(e).

basic_regex& operator=(basic_regex&& e) noexcept;

-2- Effects: returns assign(std::move(e)).

and

basic_regex& assign(const basic_regex& that);

-7- Effects: copies that into *this and returns *this.

-8- Postconditions: flags() and mark_count() return that.flags() and that.mark_count(), respectively.

basic_regex& assign(basic_regex&& that) noexcept;

-9- Effects: move assigns from that into *this and returns *this.

-10- Postconditions: flags() and mark_count() return the values that that.flags() and that.mark_count(), respectively, had before assignment. that is in a valid state with unspecified value.

History
Date User Action Args
2016-02-10 00:48:28adminsetmessages: + msg7978
2016-02-10 00:48:28adminsetstatus: new -> nad
2016-02-07 20:24:45adminsetmessages: + msg7969
2016-01-05 00:00:00admincreate