<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 123: Should valarray helper arrays fill functions be const?</title>
<meta property="og:title" content="Issue 123: Should valarray helper arrays fill functions be const?">
<meta property="og:description" content="C++ library issue. Status: CD1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue123.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="123"><a href="lwg-defects.html#123">123</a>. Should valarray helper arrays fill functions be const?</h3>
<p><b>Section:</b> 29.6.5.4 <a href="https://wg21.link/slice.arr.fill">[slice.arr.fill]</a>, 29.6.7.4 <a href="https://wg21.link/gslice.array.fill">[gslice.array.fill]</a>, 29.6.8.4 <a href="https://wg21.link/mask.array.fill">[mask.array.fill]</a>, 29.6.9.4 <a href="https://wg21.link/indirect.array.fill">[indirect.array.fill]</a> <b>Status:</b> <a href="lwg-active.html#CD1">CD1</a>
 <b>Submitter:</b> Judy Ward <b>Opened:</b> 1998-12-15 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#CD1">CD1</a> status.</p>
<p><b>Discussion:</b></p>
<p>One of the operator= in the valarray helper arrays is const and one
is not. For example, look at slice_array. This operator= in Section
29.6.5.2 <a href="https://wg21.link/slice.arr.assign">[slice.arr.assign]</a> is const: </p>

<p>&nbsp;&nbsp;&nbsp; <code>void operator=(const valarray&lt;T&gt;&amp;) const;</code> </p>

<p>but this one in Section 29.6.5.4 <a href="https://wg21.link/slice.arr.fill">[slice.arr.fill]</a> is not: </p>

<p>&nbsp;&nbsp;&nbsp; <code>void operator=(const T&amp;); </code></p>

<p>The description of the semantics for these two functions is similar. </p>


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

<p>29.6.5 <a href="https://wg21.link/template.slice.array">[template.slice.array]</a> Template class slice_array</p>
<blockquote>

   <p>In the class template definition for slice_array, replace the member
   function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>with</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.5.4 <a href="https://wg21.link/slice.arr.fill">[slice.arr.fill]</a> slice_array fill function</p>
<blockquote>

   <p>Change the function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>to</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.7 <a href="https://wg21.link/template.gslice.array">[template.gslice.array]</a> Template class gslice_array</p>
<blockquote>

   <p>In the class template definition for gslice_array, replace the member
   function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>with</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.7.4 <a href="https://wg21.link/gslice.array.fill">[gslice.array.fill]</a> gslice_array fill function</p>
<blockquote>

   <p>Change the function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>to</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.8 <a href="https://wg21.link/template.mask.array">[template.mask.array]</a> Template class mask_array</p>
<blockquote>

   <p>In the class template definition for mask_array, replace the member
   function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>with</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.8.4 <a href="https://wg21.link/mask.array.fill">[mask.array.fill]</a> mask_array fill function</p>
<blockquote>

   <p>Change the function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>to</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.9 <a href="https://wg21.link/template.indirect.array">[template.indirect.array]</a> Template class indirect_array</p>
<blockquote>

   <p>In the class template definition for indirect_array, replace the member
   function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>with</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>

<p>29.6.9.4 <a href="https://wg21.link/indirect.array.fill">[indirect.array.fill]</a> indirect_array fill function</p>
<blockquote>

   <p>Change the function declaration</p>
    <pre>
      void operator=(const T&amp;);
    </pre>
   <p>to</p>
    <pre>
      void operator=(const T&amp;) const;
    </pre>
</blockquote>


<p><i>[Redmond: Robert provided wording.]</i></p>




<p><b>Rationale:</b></p>
<p>There's no good reason for one version of operator= being const and
another one not.  Because of issue <a href="lwg-defects.html#253" title="valarray helper functions are almost entirely useless (Status: CD1)">253</a><sup><a href="https://cplusplus.github.io/LWG/issue253" title="Latest snapshot">(i)</a></sup>, this now
matters: these functions are now callable in more circumstances.  In
many existing implementations, both versions are already const.</p>





</body>
</html>
