Title
locale's copy assignment operator should return locale&
Status
new
Section
[locale]
Submitter
Stephan T. Lavavej

Created on 2019-12-06.00:00:00 last changed 2 months ago

Messages

Date: 2019-12-21.14:14:21

Proposed resolution:

This wording is relative to N4842.

  1. Modify [locale] as indicated:

    […]
    ~locale(); // not virtual
    const locale& operator=(const locale& other) noexcept;
    template<class Facet> locale combine(const locale& other) const;
    […]
    
  2. Modify [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.

Date: 2019-12-21.00:00:00

[ 2019-12-21 Issue Prioritization ]

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

Date: 2019-12-06.00:00:00

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

  • Weird!

  • The only occurrence in the entire Standard Library.

  • Preventing locale from satisfying std::copyable.

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.)

History
Date User Action Args
2019-12-21 14:14:21adminsetmessages: + msg10896
2019-12-07 18:23:16adminsetmessages: + msg10870
2019-12-06 00:00:00admincreate