<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 731: proposal for a customizable seed_seq</title>
<meta property="og:title" content="Issue 731: proposal for a customizable seed_seq">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue731.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#NAD">NAD</a> status.</em></p>
<h3 id="731"><a href="lwg-closed.html#731">731</a>. proposal for a customizable <code>seed_seq</code></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#NAD">NAD</a>
 <b>Submitter:</b> Stephan Tolksdorf <b>Opened:</b> 2007-09-21 <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#rand.util.seedseq">issues</a> in [rand.util.seedseq].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The proper way to seed random number engines seems to be the most frequently 
discussed issue of the 29.5 <a href="https://wg21.link/rand">[rand]</a> proposal. While the new <code>seed_seq</code> approach is already rather 
general and probably sufficient for most situations, it is unlikely to be optimal in every case (one 
problem was pointed out in point T5 above). In some situations it might, for instance, be better to 
seed the state with a cryptographic generator. 
</p>
<p>
In my opinion this is a pretty strong argument for extending the standard with a simple facility to 
customize the seeding procedure. This could, for example, be done with the following minimal 
changes:
</p>

<p>
<b>Possible resolution:</b>
</p>

<ol style="list-style-type:lower-alpha">
<li>
Turn the interface specification of 29.5.8.1 <a href="https://wg21.link/rand.util.seedseq">[rand.util.seedseq]</a>/2 into a "SeedSeq" requirement, where the 
exact behaviour of the constructors and the randomize method are left unspecified and where the
const qualification for randomize is removed. Classes implementing this interface are additionally 
required to specialize the traits class in c).
</li>
<li>
Provide the class <code>seed_seq</code> as a default implementation of the SeedSeq interface.
</li>
<li>
<p>
Supplement the <code>seed_seq</code> with a traits class
</p>
<blockquote><pre>
template &lt;typename T&gt; 
struct is_seed_seq { static const bool value = false; }
</pre></blockquote>
<p>and the specialization</p>
<blockquote><pre>
template &lt;&gt; 
struct is_seed_seq&lt;seed_seq&gt; { static const bool value = true; }
</pre></blockquote>
<p>which users can supplement with further specializations.</p>
</li>
<li>
Change 29.5.3.4 <a href="https://wg21.link/rand.req.eng">[rand.req.eng]</a>/1 d) to "q is an lvalue of a type that fulfils the SeedSeq requirements", and 
modify the constructors and seed methods in 29.5.4 <a href="https://wg21.link/rand.eng">[rand.eng]</a> appropriately (the actual implementation 
could be done using the SFINAE technique).
</li>
</ol>

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


<blockquote><p>
See N2424. Close NAD but note that "conceptizing" the library may cause
this problem to be solved by that route.
</p></blockquote>


<p id="res-731"><b>Proposed resolution:</b></p>
<p>
See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2424.pdf">N2424</a>
for the proposed resolution.
</p>





</body>
</html>
