3353. locale's copy assignment operator should return locale&

Section: 28.3.3.1 [locale] Status: New Submitter: Stephan T. Lavavej Opened: 2019-12-06 Last modified: 2019-12-21

Priority: 3

View all other issues in [locale].

View all issues with New status.

Discussion:

Curiously, locale's copy assignment operator currently returns const locale&. As Casey Carter noted in microsoft/STL#268, this is:

We aren't aware of any reason for this to be const. (I observe that this hasn't changed since N1804 on 2005-04-27 and probably goes back to C++98; I suspect that when this was originally specified, copy assignment operators were relatively new, and conventions for them weren't rigorously followed.)

[2019-12-21 Issue Prioritization]

Priority to 3 after reflector discussion based on the observation that we have implementation divergence.

Proposed resolution:

This wording is relative to N4842.

  1. Modify 28.3.3.1 [locale] as indicated:

    […]
    ~locale(); // not virtual
    const locale& operator=(const locale& other) noexcept;
    template<class Facet> locale combine(const locale& other) const;
    […]
    
  2. Modify 28.3.3.1.3 [locale.cons] as indicated:

    const locale& operator=(const locale& other) noexcept;
    

    -14- Effects: Creates a copy of other, replacing the current value.

    -15- Returns: *this.