<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 782: Extended seed_seq constructor is useless</title>
<meta property="og:title" content="Issue 782: Extended seed_seq constructor is useless">
<meta property="og:description" content="C++ library issue. Status: CD1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue782.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="782"><a href="lwg-defects.html#782">782</a>. Extended <code>seed_seq</code> constructor is useless</h3>
<p><b>Section:</b> 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a> <b>Status:</b> <a href="lwg-active.html#CD1">CD1</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2008-01-27 <b>Last modified:</b> 2015-10-20</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#rand.util.seedseq">issues</a> in [rand.util.seedseq].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#CD1">CD1</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Part of the resolution of n2423, issue 8 was the proposal to
extend the <code>seed_seq</code> constructor accepting an input range
as follows (which is now part of N2461):
</p>

<blockquote><pre>
template&lt;class InputIterator,
size_t u = numeric_limits&lt;iterator_traits&lt;InputIterator&gt;::value_type&gt;::digits&gt;
seed_seq(InputIterator begin, InputIterator end);
</pre></blockquote>

<p>
First, the expression <code>iterator_traits&lt;InputIterator&gt;::value_type</code>
is invalid due to missing <code>typename</code> keyword, which is easy to
fix.
</p>

<p>
Second (and worse), while the language now supports default
template arguments of function templates, this customization
point via the second <code>size_t</code> template parameter is of no advantage,
because <code>u</code> can never be deduced, and worse - because it is a
constructor function template - it can also never be explicitly
provided (13.10.2 <a href="https://wg21.link/temp.arg.explicit">[temp.arg.explicit]</a>/7).
</p>

<p>
The question arises, which advantages result from a compile-time
knowledge of <code>u</code> versus a run time knowledge? If run time knowledge
suffices, this parameter should be provided as normal function
default argument [Resolution marked (A)], if compile-time knowledge
is important, this could be done via a tagging template or more
user-friendly via a standardized helper generator function
(<code>make_seed_seq</code>), which allows this [Resolution marked (B)].
</p>

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


<blockquote>
<p>
Fermilab does not have a strong opinion. Would prefer to go with
solution A. Bill agrees that solution A is a lot simpler and does the
job.
</p>
<p>
Proposed Resolution: Accept Solution A.
</p>
</blockquote>

<p>
Issue <a href="lwg-defects.html#803" title="Simplification of seed_seq::seq_seq (Status: Resolved)">803</a><sup><a href="https://cplusplus.github.io/LWG/issue803" title="Latest snapshot">(i)</a></sup> claims to make this issue moot.
</p>



<p id="res-782"><b>Proposed resolution:</b></p>
<ol style="list-style-type:upper-alpha">
<li>
<p>
In 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>/2, class <code>seed_seq</code> synopsis replace:
</p>

<blockquote><pre>
class seed_seq 
{ 
public:
   ...
   template&lt;class InputIterator<del>,
      size_t u = numeric_limits&lt;iterator_traits&lt;InputIterator&gt;::value_type&gt;::digits</del>&gt;
          seed_seq(InputIterator begin, InputIterator end<ins>,
          size_t u = numeric_limits&lt;typename iterator_traits&lt;InputIterator&gt;::value_type&gt;::digits</ins>);
   ...
};
</pre></blockquote>

<p>
and do a similar replacement in the member description between
p.3 and p.4.
</p>
</li>

<li>
<p>
In 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>/2, class <code>seed_seq</code> synopsis <em>and</em> in the
member description between p.3 and p.4 replace:
</p>

<blockquote><pre>
template&lt;class InputIterator<del>,
  size_t u = numeric_limits&lt;iterator_traits&lt;InputIterator&gt;::value_type&gt;::digits</del>&gt;
      seed_seq(InputIterator begin, InputIterator end);
<ins>template&lt;class InputIterator, size_t u&gt;
seed_seq(InputIterator begin, InputIterator end, <i>implementation-defined</i> s);</ins>
</pre></blockquote>

<p>
In 29.5.2 <a href="https://wg21.link/rand.synopsis">[rand.synopsis]</a>, header <code>&lt;random&gt;</code> synopsis, immediately after the
class <code>seed_seq</code> declaration <em>and</em> in 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>/2, immediately
after the class <code>seed_seq</code> definition add:
</p>

<blockquote><pre>
template&lt;size_t u, class InputIterator&gt;
  seed_seq make_seed_seq(InputIterator begin, InputIterator end);
</pre></blockquote>

<p>
In 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>, just before p.5 insert two paragraphs:
</p>

<blockquote>
<p>
The first constructor behaves as if it would provide an
integral constant expression <code>u</code> of type <code>size_t</code> of value
<code>numeric_limits&lt;typename iterator_traits&lt;InputIterator&gt;::value_type&gt;::digits</code>.
</p>
<p>
The second constructor uses an implementation-defined mechanism
to provide an integral constant expression <code>u</code> of type <code>size_t</code> and
is called by the function <code>make_seed_seq</code>.
</p>
</blockquote>

<p>
In 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>, just after the last paragraph add:
</p>

<blockquote>
<pre>
template&lt;size_t u, class InputIterator&gt;
   seed_seq make_seed_seq(InputIterator begin, InputIterator end);
</pre>
<blockquote>
<p>
where <code>u</code> is used to construct an object <code>s</code> of implementation-defined type.
</p>
<p>
<i>Returns:</i> <code>seed_seq(begin, end, s)</code>;
</p>
</blockquote>
</blockquote>

</li>
</ol>






</body>
</html>
