<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3641: Add operator== to format_to_n_result</title>
<meta property="og:title" content="Issue 3641: Add operator== to format_to_n_result">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3641.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#New">New</a> status.</em></p>
<h3 id="3641"><a href="lwg-active.html#3641">3641</a>. Add <code>operator==</code> to <code>format_to_n_result</code></h3>
<p><b>Section:</b> 28.5.1 <a href="https://wg21.link/format.syn">[format.syn]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Mark de Wever <b>Opened:</b> 2021-11-14 <b>Last modified:</b> 2022-01-30</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#format.syn">active issues</a> in [format.syn].</p>
<p><b>View all other</b> <a href="lwg-index.html#format.syn">issues</a> in [format.syn].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
During the 2019 Cologne meeting the papers <a href="https://wg21.link/P1614R2" title=" The Mothership Has Landed: Adding <=> to the Library">P1614R2</a> "The Mothership has
Landed" and <a href="https://wg21.link/P0645R10" title=" Text Formatting">P0645R10</a> "Text Formatting" have been accepted. P1614R2 adds
<code>operator==</code> to <code>to_chars_result</code> and <code>from_chars_result</code>. P0645R10 
adds a similar type <code>format_to_n_result</code> <em>without</em> an <code>operator==</code>. 
LWG <a href="lwg-defects.html#3373" title="{to,from}_chars_result and format_to_n_result need the
 &quot;we really mean what we say&quot; wording (Status: C++20)">3373</a><sup><a href="https://cplusplus.github.io/LWG/issue3373" title="Latest snapshot">(i)</a></sup> reaffirms these three types are similar by ensuring they can be used in
structured bindings.
<p/>
It seems due to accepting P1614R2 and P0645R10 during the same meeting the addition of 
<code>operator==</code> wasn't applied to <code>format_to_n_result</code>. I propose to add 
<code>operator==</code> to <code>format_to_n_result</code> to keep these types similar.
<p/>
The <code>Out</code> template argument of <code>format_to_n_result</code> is unconstrained. Since
it's returned from <code>format_to_n</code> it's indirectly constrained to an 
<code>output_iterator</code>. An <code>output_iterator</code> doesn't require <code>equality_comparable</code>,
thus the defaulted <code>operator==</code> can be defined deleted.
</p>

<p><i>[2022-01-30; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
Several votes for NAD. Unclear why <code>to_chars_result</code> is equality
comparable, but whatever the reason, this is unrelated to them and doesn't
need to be.
</p>



<p id="res-3641"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4901" title=" Working Draft, Standard for Programming Language C++">N4901</a>.
</p>

<ol>

<li><p>Modify 28.5.1 <a href="https://wg21.link/format.syn">[format.syn]</a>, header <code>&lt;format&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
[&hellip;]
template&lt;class Out&gt; struct format_to_n_result {
  Out out;
  iter_difference_t&lt;Out&gt; size;
  <ins>friend bool operator==(const format_to_n_result&amp;, const format_to_n_result&amp;) = default;</ins>
};
[&hellip;]
</pre>
</blockquote>
</li>

</ol>





</body>
</html>
