<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3935: template&lt;class X&gt; constexpr complex&amp; operator=(const complex&lt;X&gt;&amp;) has no specification</title>
<meta property="og:title" content="Issue 3935: template&lt;class X&gt; constexpr complex&amp; operator=(const complex&lt;X&gt;&amp;) has no specification">
<meta property="og:description" content="C++ library issue. Status: WP">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3935.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#WP">WP</a> status.</em></p>
<h3 id="3935"><a href="lwg-defects.html#3935">3935</a>. <code>template&lt;class X&gt; constexpr complex&amp; operator=(const complex&lt;X&gt;&amp;)</code> has no specification</h3>
<p><b>Section:</b> 29.4.3 <a href="https://wg21.link/complex">[complex]</a> <b>Status:</b> <a href="lwg-active.html#WP">WP</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2023-05-21 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#complex">active issues</a> in [complex].</p>
<p><b>View all other</b> <a href="lwg-index.html#complex">issues</a> in [complex].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#WP">WP</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The class template <code>complex</code> synopsis in 29.4.3 <a href="https://wg21.link/complex">[complex]</a> shows the following member function template:
</p>
<blockquote><pre>
template&lt;class X&gt; constexpr complex&amp; operator= (const complex&lt;X&gt;&amp;);
</pre></blockquote>
<p>
but does not specify its semantics. This affects a code example such as the following one:
</p>
<blockquote><pre>
#include &lt;complex&gt;

int main()
{
  std::complex&lt;double&gt; zd(1, 1);
  std::complex&lt;float&gt; zf(2, 0);
  zd = zf;
}
</pre></blockquote>
<p>
This problem exists since the 1998 version of the standard (at that time this was declared in subclause [lib.complex]),
and even though this looks like a "copy-assignment-like" operation, its effects aren't implied by our general
16.3.3.5 <a href="https://wg21.link/functions.within.classes">[functions.within.classes]</a> wording (a function template is never considered as copy assignment operator,
see 11.4.6 <a href="https://wg21.link/class.copy.assign">[class.copy.assign]</a>).
<p/>
It should be point out that the refactoring done by <a href="https://wg21.link/P1467R9" title=" Extended floating-point types and standard names">P1467R9</a> had caused some other members to become finally
specified that were not specified before, but in addition to LWG <a href="lwg-active.html#3934" title="std::complex&lt;T&gt;::operator=(const T&amp;) has no specification (Status: New)">3934</a><sup><a href="https://cplusplus.github.io/LWG/issue3934" title="Latest snapshot">(i)</a></sup>'s observation about the missing
specification of the assignment operator taking a value type as parameter, this is now an additional currently unspecified 
member, but unaffected by any decision on LWG <a href="lwg-active.html#3933" title="P1467R9 accidentally changed the signatures of certain constructors of std::complex (Status: New)">3933</a><sup><a href="https://cplusplus.github.io/LWG/issue3933" title="Latest snapshot">(i)</a></sup>.
</p>


<p><i>[2023-06-01; Reflector poll]</i></p>

<p>
Set status to Tentatively Ready after eight votes in favour during reflector poll.
</p>

<p><i>[2023-06-17 Approved at June 2023 meeting in Varna. Status changed: Voting &rarr; WP.]</i></p>



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

<li>
<p>Add a new prototype specification between the current paragraphs 8 and 9 of 29.4.5 <a href="https://wg21.link/complex.member.ops">[complex.member.ops]</a> as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note</i>: Similar to the proposed wording for LWG <a href="lwg-active.html#3934" title="std::complex&lt;T&gt;::operator=(const T&amp;) has no specification (Status: New)">3934</a><sup><a href="https://cplusplus.github.io/LWG/issue3934" title="Latest snapshot">(i)</a></sup>, the wording form used below intentionally 
deviates from the rest of the [complex.member.ops] wording forms, because it seems much simpler and clearer to follow the wording 
forms used that specify the effects of <code>imag</code> and <code>real</code> functions plus borrowing relevant parts from 
29.4.4 <a href="https://wg21.link/complex.members">[complex.members]</a> p2.]
</p>
</blockquote>

<blockquote>
<pre>
constexpr complex&amp; operator/=(const T&amp; rhs);
</pre>
<blockquote>
<p>
[&hellip;]
</p>
</blockquote>
<pre>
<ins>template&lt;class X&gt; constexpr complex&amp; operator=(const complex&lt;X&gt;&amp; rhs);</ins>
</pre>
<blockquote>
<p>
<ins>-?- <i>Effects</i>: Assigns the value <code>rhs.real()</code> to the real part and the value 
<code>rhs.imag()</code> to the imaginary part of the complex value <code>*this</code>.</ins>
<p/>
<ins>-?- <i>Returns</i>: <code>*this</code>.</ins>
</p>
</blockquote>
<pre>
template&lt;class X&gt; constexpr complex&amp; operator+=(const complex&lt;X&gt;&amp; rhs);
</pre>
<blockquote>
<p>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>

</ol>






</body>
</html>
