title: packaged_task example problem? Stroustrup example modification
body: <p>I'm trying to modify the example given in Stroustrup C++ 4th Ed Page 122 to call the accumulator() function directly with iterators.  Specifically remove use of *double and use iterators.</p>
  
  <p>So far, I have this, however it has compilation problems which I don't understand.</p>
  
  <p>Does anyone have any pointers on accomplishing this?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;thread&gt;
  #include &lt;numeric&gt;
  #include &lt;vector&gt;
  #include &lt;future&gt;
  using namespace std;
  
  double comp2(vector&lt;double&gt;&amp; v) {
    using Task_type = double(vector&lt;double&gt;::iterator,
                 vector&lt;double&gt;::iterator, double);
  
    packaged_task&lt;Task_type&gt; pt0 {accumulate};
    packaged_task&lt;Task_type&gt; pt1 {accumulate};
  
  #if 0
    future&lt;double&gt; f0 {pt0.get_future()};
    future&lt;double&gt; f1 {pt1.get_future()};
  
    double *first = &amp;v[0];
    // move required bc package_task cannot be copied
    thread t1 {move(pt0), first, first + v.size()/2, 0};
    thread t2 {move(pt1), first + v.size()/2, first + v.size(), 0};
  
    t1.join();
    t2.join();
  
    return f0.get() + f1.get();
  #endif
  }
  
  int main(int argc, char *argv[])
  {
    vector&lt;double&gt; v = {1.0, 1.0, 1.0, 1.0};
  
    cout &lt;&lt; "v: " &lt;&lt; comp2(v) &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>and the error is:</p>
  
  <pre><code>g++ -lpthread -pedantic -Wall test87.cc &amp;&amp; ./a.out
  test87.cc: In function ‘double comp2(std::vector&lt;double&gt;&amp;)’:
  test87.cc:13:43: error: no matching function for call to ‘std::packaged_task&lt;double(__gnu_cxx::__normal_iterator&lt;double*, std::vector&lt;double&gt; &gt;, __gnu_cxx::__normal_iterator&lt;double*, std::vector&lt;double&gt; &gt;, double)&gt;::packaged_task(&lt;brace-enclosed initializer list&gt;)’
     packaged_task&lt;Task_type&gt; pt0 {accumulate};
                                             ^
  In file included from test87.cc:6:
  /usr/include/c++/8/future:1528:2: note: candidate: ‘template&lt;class _Allocator&gt; std::packaged_task&lt;_Res(_ArgTypes ...)&gt;::packaged_task(std::allocator_arg_t, const _Allocator&amp;, std::packaged_task&lt;_Res(_ArgTypes ...)&gt;&amp;&amp;)’
    packaged_task(allocator_arg_t, const _Allocator&amp;,
    ^~~~~~~~~~~~~
  /usr/include/c++/8/future:1528:2: note:   template argument deduction/substitution failed:
  test87.cc:13:43: note:   candidate expects 3 arguments, 1 provided
     packaged_task&lt;Task_type&gt; pt0 {accumulate};
  </code></pre>