<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 776: Undescribed assign function of std::array</title>
<meta property="og:title" content="Issue 776: Undescribed assign function of std::array">
<meta property="og:description" content="C++ library issue. Status: CD1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue776.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#CD1">CD1</a> status.</em></p>
<h3 id="776"><a href="lwg-defects.html#776">776</a>. Undescribed <code>assign</code> function of <code>std::array</code></h3>
<p><b>Section:</b> 23.3.3 <a href="https://wg21.link/array">[array]</a> <b>Status:</b> <a href="lwg-active.html#CD1">CD1</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2008-01-20 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#array">issues</a> in [array].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#CD1">CD1</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The class template array synopsis in 23.3.3 <a href="https://wg21.link/array">[array]</a> p. 3 declares a member
function
</p>

<blockquote><pre>
void assign(const T&amp; u);
</pre></blockquote>

<p>
which's semantic is no-where described. Since this signature is
not part of the container requirements, such a semantic cannot
be derived by those.
</p>

<p>
I found only one reference to this function in the issue list,
<a href="lwg-closed.html#588" title="requirements on zero sized tr1::arrays and other details (Status: NAD)">588</a><sup><a href="https://cplusplus.github.io/LWG/issue588" title="Latest snapshot">(i)</a></sup> where the question is raised:
</p>

<blockquote><p>
what's the effect of calling <code>assign(T&amp;)</code> on a zero-sized array?
</p></blockquote>

<p>
which does not answer the basic question of this issue.
</p>

<p>
If this function shall be part of the <code>std::array</code>, it's probable
semantic should correspond to that of <code>boost::array</code>, but of
course such wording must be added.
</p>


<p id="res-776"><b>Proposed resolution:</b></p>
<p>
Just after the section  [array.data] add the following new section:
</p>

<p>
23.2.1.5 array::fill [array.fill]
</p>

<blockquote>
<pre>
void fill(const T&amp; u);
</pre>

<p>
1: <i>Effects:</i> <code>fill_n(begin(), N, u)</code>
</p>
</blockquote>

<p>
[N.B: I wonder, why class <code>array</code> does not have a "modifiers"
section. If it had, then <code>assign</code> would naturally belong to it]
</p>

<p>
Change the synopsis in 23.3.3 <a href="https://wg21.link/array">[array]</a>/3:
</p>

<blockquote><pre>
template &lt;class T, size_t N&gt;
struct array { 
  ...
  void <del>assign</del> <ins>fill</ins>(const T&amp; u);
  ...
</pre></blockquote>


<p><i>[
Bellevue:
]</i></p>


<blockquote>
<p>
Suggest substituting "fill" instead of "assign".
</p>
<p>
Set state to Review given substitution of "fill" for "assign".
</p>
</blockquote>




</body>
</html>
