<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2295: Locale name when the provided Facet is a nullptr</title>
<meta property="og:title" content="Issue 2295: Locale name when the provided Facet is a nullptr">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2295.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++23">C++23</a> status.</em></p>
<h3 id="2295"><a href="lwg-defects.html#2295">2295</a>. Locale name when the provided <code>Facet</code> is a <code>nullptr</code></h3>
<p><b>Section:</b> 28.3.3.1.3 <a href="https://wg21.link/locale.cons">[locale.cons]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Juan Soulie <b>Opened:</b> 2013-09-04 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#locale.cons">issues</a> in [locale.cons].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p>
28.3.3.1.3 <a href="https://wg21.link/locale.cons">[locale.cons]</a> p14 ends with:
</p>
<blockquote><p>
"[&hellip;] If <code>f</code> is null, the resulting object is a copy of <code>other</code>."
</p></blockquote>
<p>
but the next line p15 says: 
</p>
<blockquote><p>
"<i>Remarks:</i> The resulting locale has no name."
</p></blockquote>
<p>
But both can't be true when <code>other</code> has a name and <code>f</code> is null.
<p/>
I've tried it on two implementations (MSVC,GCC) and they are inconsistent with each other on this.
</p>
<p>
Daniel Kr&uuml;gler:
<p/>
As currently written, the <i>Remarks</i> element applies unconditionally for all cases and thus should
"win". The question arises whether the introduction of this element by LWG <a href="lwg-closed.html#424" title="normative notes (Status: NAD Editorial)">424</a><sup><a href="https://cplusplus.github.io/LWG/issue424" title="Latest snapshot">(i)</a></sup> had actually intended
to change the previous <i>Note</i> to a <i>Remarks</i> element. In either case the wording should be improved
to clarify this special case.
</p>

<p><i>[2022-02-14; Daniel comments]</i></p>

<p>
This issue seems to have some overlap with LWG <a href="lwg-defects.html#3676" title="Name of locale composed using std::locale::none (Status: Resolved)">3676</a><sup><a href="https://cplusplus.github.io/LWG/issue3676" title="Latest snapshot">(i)</a></sup> so both should presumably be resolved
in a harmonized way.
</p>

<p><i>[2022-11-01; Jonathan provides wording]</i></p>

<p>
This also resolves <a href="lwg-defects.html#3673" title="&sect;[locale.cons] Ambiguous argument in Throws for locale+name+category constructor (Status: Resolved)">3673</a><sup><a href="https://cplusplus.github.io/LWG/issue3673" title="Latest snapshot">(i)</a></sup> and <a href="lwg-defects.html#3676" title="Name of locale composed using std::locale::none (Status: Resolved)">3676</a><sup><a href="https://cplusplus.github.io/LWG/issue3676" title="Latest snapshot">(i)</a></sup>.
</p>

<p><i>[2022-11-04; Jonathan revises wording after feedback]</i></p>

<p>Revert an incorrect edit to p8, which was incorrectly changed to:</p>
<p>
"If <code>cats</code> is equal to <code>locale::none</code>, the resulting locale
has the same name as <code>locale(std_name)</code>. Otherwise, the locale
has a name if and only if <code>other</code> has a name."
</p>

<p><i>[Kona 2022-11-08; Move to Ready status]</i></p>


<p><i>[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting &rarr; WP.]</i></p>



<p id="res-2295"><b>Proposed resolution:</b></p>

<p>
This wording is relative to <a href="https://wg21.link/N4917" title=" Working Draft, Standard for Programming Language C++">N4917</a>.
</p>

<ol>
<li><p>Modify 28.3.3.1.3 <a href="https://wg21.link/locale.cons">[locale.cons]</a> as indicated:</p>

<blockquote>
<blockquote><pre>
explicit locale(const char* std_name);
</pre></blockquote>
<blockquote>
<p>-2- <i>Effects</i>:
Constructs a locale using standard C locale names, e.g., <code>"POSIX"</code>.
The resulting locale implements semantics defined to be associated with that name.
</p>
<p>-3- <i>Throws</i>:
<code>runtime_error</code> if the argument is not valid, or is null.
</p>
<p>-4- <i>Remarks</i>:
The set of valid string argument values is <code>"C"</code>, <code>""</code>,
and any implementation-defined values.
</p>
</blockquote>

<blockquote><pre>
explicit locale(const string&amp; std_name);
</pre></blockquote>
<blockquote>
<p>-5- <i>Effects</i>:
<del>The same as</del><ins>Equivalent to</ins>
<code>locale(std_name.c_str())</code>.
</p>
</blockquote>

<blockquote><pre>
locale(const locale&amp; other, const char* std_name, category <ins>cats</ins>);
</pre></blockquote>
<blockquote>
<p><ins>-?- <i>Preconditions</i>:
<code>cats</code> is a valid <code>category</code> value
(28.3.3.1.2.1 <a href="https://wg21.link/locale.category">[locale.category]</a>).
</ins></p>
<p>-6- <i>Effects</i>:
Constructs a locale as a copy of <code>other</code> except for the facets
identified by the <code>category</code> argument, which instead implement
the same semantics as <code>locale(std_name)</code>.
</p>
<p>-7- <i>Throws</i>:
<code>runtime_error</code> if the <ins>second</ins> argument is not valid,
or is null.
</p>
<p>-8- <i>Remarks</i>:
The locale has a name if and only if <code>other</code> has a name.
</p>
</blockquote>

<blockquote><pre>
locale(const locale&amp; other, const string&amp; std_name, category cat<ins>s</ins>);
</pre></blockquote>
<blockquote>
<p>-9- <i>Effects</i>:
<del>The same as</del><ins>Equivalent to</ins>
<code>locale(other, std_name.c_str(), cat<ins>s</ins>)</code>.
</p>
</blockquote>

<blockquote><pre>
template&lt;class Facet&gt; locale(const locale&amp; other, Facet* f);
</pre></blockquote>
<blockquote>
<p>-10- <i>Effects</i>: Constructs a locale incorporating all facets from the
first argument except that of type <code>Facet</code>,
and installs the second argument as the remaining facet.
If <code>f</code> is null, the resulting object is a copy of <code>other</code>.
</p>
<p>-11- <em>Remarks</em>:
<ins>If <code>f</code> is null,
the resulting locale has the same name as <code>other</code>.
Otherwise, the</ins>
<del>The</del>
resulting locale has no name.
</p>
</blockquote>

<blockquote><pre>
locale(const locale&amp; other, const locale&amp; one, category cats);
</pre></blockquote>
<blockquote>
<p><ins>-?- <i>Preconditions</i>:
<code>cats</code> is a valid <code>category</code> value.
</ins></p>
<p>-12- <i>Effects</i>:
Constructs a locale incorporating all facets from the first argument
except for those that implement <code>cats</code>, which are instead
incorporated from the second argument.
</p>
<p>-13- <i>Remarks</i>:
<ins>If <code>cats</code> is equal to <code>locale::none</code>,
the resulting locale has a name if and only if the first argument has a name.
Otherwise, the</ins>
<del>The</del>
locale has a name if and only if the first two arguments
<ins>both</ins>
have names.
</p>
</blockquote>

</blockquote>
</li>
</ol>






</body>
</html>
