<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2963: Algorithms with underspecified iterator requirements</title>
<meta property="og:title" content="Issue 2963: Algorithms with underspecified iterator requirements">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2963.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#New">New</a> status.</em></p>
<h3 id="2963"><a href="lwg-active.html#2963">2963</a>. Algorithms with underspecified iterator requirements</h3>
<p><b>Section:</b> 26 <a href="https://wg21.link/algorithms">[algorithms]</a>, 29 <a href="https://wg21.link/numerics">[numerics]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Ga&scaron;per A&zcaron;man <b>Opened:</b> 2017-05-10 <b>Last modified:</b> 2017-07-12</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#algorithms">active issues</a> in [algorithms].</p>
<p><b>View all other</b> <a href="lwg-index.html#algorithms">issues</a> in [algorithms].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
While researching whether the proposed resolution of Iterators of Containers of move-only types do not model <code>InputIterator</code>
(LWG <a href="lwg-active.html#2962" title="Iterators of Containers of move-only types do not model InputIterator (Status: Open)">2962</a><sup><a href="https://cplusplus.github.io/LWG/issue2962" title="Latest snapshot">(i)</a></sup>), I came across several algorithms that underspecify their requirements, mostly with regard to some associated type of the iterator type they operate on. A list can be found below.
<p/>
The list of algorithms with underspecified requirements from <code>&lt;algorithm&gt;</code> and <code>&lt;numeric&gt;</code> follows.
<p/>
With the advent of concepts, these algorithms will need better specifications if we are ever hoping to be allowed to overload based on them. I want this issue to bring the standard algorithms closer to having their concept requirements directly transcribable to library annotations.
<p/>
Suggested resolution:
</p>
<ol>
<li>
<p><code>copy</code>, <code>copy_if</code>, <code>copy_n</code>, <code>copy_backward</code></p>
<p>Add to description: <ins><code>*result</code> shall be assignable from <code>*first</code>.</ins></p>
</li>
<li>
<p><code>move</code>, <code>move_backward</code></p>
<p>Add to description: <ins><code>*result</code> shall be move-assignable from <code>*first</code>.</ins></p>
</li>
<li>
<p><code>transform</code></p>
<p>Add to description: <ins>The result of the expression <code>op(*first)</code> or <code>binary_op(*first1, *first2)</code> 
shall be writable to <code>result</code>.</ins></p>
</li>
<li>
<p><code>rotate_copy</code></p>
<p>Add to description: <ins><code>*first</code> shall be writable to <code>result</code>.</ins></p>
</li>
<li>
<p><code>merge</code></p>
<p>Add to description: <ins><code>*first1</code> and <code>*first2</code> shall be writable to <code>result</code>.</ins>.</p>
</li>
<li>
<p><code>set_union</code>, <code>set_intersection</code>, <code>set_difference</code>, <code>set_symmetric_difference</code></p>
<p>Add to description: <ins><code>*first1</code> and <code>*first2</code> shall be writable to <code>result</code>.</ins></p>
</li>
<li>
<p><code>partial_sum</code></p>
<p>
<code>acc</code> is not defined.
<p/>
Change description: <code>acc</code>, a variable of <code>InputIterator</code>'s value type, shall be constructible
</p>
</li>
<li>
<p><code>adjacent_difference</code></p>
<p>
<code>acc</code> is not defined.
<p/>
Change description: <code>acc</code>, a variable of <code>InputIterator</code>'s value type, shall be <code>MoveAssignable</code> and shall be 
<code>constructible</code> from the type of <code>*first</code>.
</p>
</li>
<li>
<p><code>iota</code></p>
<p>
<code>iota</code> is mis-specified. Since the expression we need to support is <code>*first = value</code>: <code>*first</code> 
is required to be of type <code>InputIterator::reference</code>, and value is an lvalue of type <code>T</code>. The current 
specification allows calling <code>iota</code> with a <code>const</code> output iterator!
<p/>
<del><code>T</code> shall be convertible to <code>ForwardIterator</code>'s value type</del><ins><code>value</code> shall be writable to 
<code>first</code>. The expression <code>*first = value</code> shall not modify <code>value</code></ins>.
</p>
</li>
</ol>

<p><i>[2017-07 Toronto Monday issue prioritization]</i></p>

<p>Priority 3; Marshall to work with Gaspar to improve wording.</p>


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





</body>
</html>
