<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1067: simplified wording for inner_product</title>
<meta property="og:title" content="Issue 1067: simplified wording for inner_product">
<meta property="og:description" content="C++ library issue. Status: NAD Concepts">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1067.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_Concepts">NAD Concepts</a> status.</em></p>
<h3 id="1067"><a href="lwg-closed.html#1067">1067</a>. simplified wording for inner_product</h3>
<p><b>Section:</b> 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a> <b>Status:</b> <a href="lwg-active.html#NAD_Concepts">NAD Concepts</a>
 <b>Submitter:</b> Alisdair Meredith <b>Opened:</b> 2009-03-17 <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#numeric.ops">issues</a> in [numeric.ops].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD Concepts">NAD Concepts</a> status.</p>
<p><b>Discussion:</b></p>

<p>
One of the motivating examples for introducing requirements-aliases was to
simplify the wording of the <code>inner_product</code> requirements.  As the paper
adopting the feature and constrained wording for the library went through in
the same meeting, it was not possible to make the change at the time.  The
simpler form should be adopted now though.  Similarly, most the other
numerical algorithms can benefit from a minor cleanup.
</p>
<p>
Note that in each case, the second more generalised form of the algorithm
does not benefit, as there are already named constraints supplied by the
template type parameters.
</p>

<p><i>[
2009-05-02 Daniel adds:
]</i></p>


<blockquote>
<p>
one part of the suggested resolution suggests the removal of the
<code>MoveConstructible&lt;T&gt;</code> requirement from
<code>inner_product</code>. According to 26.10.5 <a href="https://wg21.link/inner.product">[inner.product]</a>
</p>

<blockquote><p>
Computes its result by initializing the accumulator <code>acc</code> with the
initial value <code>init</code>
</p></blockquote>

<p>
this step requires at least <code>MoveConstructible</code>.
</p>

<p>
Therefore I strongly suggest to take this removal back (Note also
that the corresponding overload with a functor argument still has
the same <code>MoveConstructible&lt;T&gt;</code> requirement).
</p>
</blockquote>

<p><i>[
Batavia (2009-05):
]</i></p>

<blockquote>
<p>
We agree with the proposed resolution as amended by Daniel's suggestion
to restore <code>MoveConstructible</code>,
reflected in the updated proposed resolution below.
</p>
<p>
Move to Tentatively Ready.
</p>
</blockquote>


<p id="res-1067"><b>Proposed resolution:</b></p>
<p>
Change in 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a> and 26.10.3 <a href="https://wg21.link/accumulate">[accumulate]</a>:
</p>

<blockquote><pre>
template &lt;InputIterator Iter, MoveConstructible T&gt;
 requires <ins>add =</ins> HasPlus&lt;T, Iter::reference&gt;
       &amp;&amp; HasAssign&lt;T, <del>HasPlus&lt;T, Iter::reference&gt;</del> <ins>add</ins>::result_type&gt;
 T accumulate(Iter first, Iter last, T init);
</pre></blockquote>

<p>
Change in 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a> and 26.10.5 <a href="https://wg21.link/inner.product">[inner.product]</a>:
</p>

<blockquote><pre>
template &lt;InputIterator Iter1, InputIterator Iter2, MoveConstructible T&gt;
  requires <ins>mult =</ins> HasMultiply&lt;Iter1::reference, Iter2::reference&gt;
        &amp;&amp; <ins>add =</ins> HasPlus&lt;T, <del>HasMultiply&lt;Iter1::reference, Iter2::reference&gt;</del> <ins>mult</ins>::result_type&gt;
        &amp;&amp; HasAssign&lt; 
             T,
             <del>HasPlus&lt;T,
                     HasMultiply&lt;Iter1::reference, Iter2::reference&gt;::result_type&gt;</del> <ins>add</ins>::result_type&gt;
  T inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
</pre></blockquote>

<p>
Change in 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a> and 26.10.7 <a href="https://wg21.link/partial.sum">[partial.sum]</a>:
</p>

<blockquote><pre>
template &lt;InputIterator InIter, OutputIterator&lt;auto, const InIter::value_type&amp;&gt; OutIter&gt;
  requires <ins>add =</ins> HasPlus&lt;InIter::value_type, InIter::reference&gt;
        &amp;&amp; HasAssign&lt;InIter::value_type,
                     <del>HasPlus&lt;InIter::value_type, InIter::reference&gt;</del> <ins>add</ins>::result_type&gt;
        &amp;&amp; Constructible&lt;InIter::value_type, InIter::reference&gt;
  OutIter partial_sum(InIter first, InIter last, OutIter result);
</pre></blockquote>

<p>
Change in 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a> and 26.10.12 <a href="https://wg21.link/adjacent.difference">[adjacent.difference]</a>:
</p>

<blockquote><pre>
template &lt;InputIterator InIter, OutputIterator&lt;auto, const InIter::value_type&amp;&gt; OutIter&gt;
  requires <ins>sub =</ins> HasMinus&lt;InIter::value_type, InIter::value_type&gt;
        &amp;&amp; Constructible&lt;InIter::value_type, InIter::reference&gt;
        &amp;&amp; OutputIterator&lt;OutIter, <del>HasMinus&lt;InIter::value_type, InIter::value_type&gt;</del> <ins>sub</ins>::result_type&gt;
        &amp;&amp; MoveAssignable&lt;InIter::value_type&gt;
  OutIter adjacent_difference(InIter first, InIter last, OutIter result);
</pre></blockquote>






</body>
</html>
