<div class="gmail_quote">On Mon, Apr 9, 2012 at 4:54 PM, Vicente J. Botet Escriba <span dir="ltr">&lt;<a href="mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Le 10/04/12 01:24, Jeffrey Lee Hellrung, Jr. a écrit :
    <blockquote type="cite">
      <div class="gmail_quote">On Mon, Apr 9, 2012 at 3:14 PM, Vicente
        J. Botet Escriba <span dir="ltr">&lt;<a href="mailto:vicente.botet@wanadoo.fr" target="_blank">vicente.botet@wanadoo.fr</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"><br>
          </div>
        </blockquote>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> There are yet some
            problems on the Boost.Thread implementation or with the
            compilers implementation.<br>
            <br>
            When I want to pass functor, as in <br>
            <br>
            A a(5);<br>
            boost::packaged_task&lt;int&gt; pt(a);<br>
            <br>
            the constructor used is packaged_task(F&amp;&amp; f) and I
            will expect packaged_task(F const&amp; f) to be use for.<br>
            Are my expectations correct?<br>
          </div>
        </blockquote>
        <div><br>
          Well...no, apparently your expectations are not correct. But
          that&#39;s slightly beside the point. I think the correct fix here
          is to remove the packaged_task(F const &amp;) overload
          entirely, since the packaged_task(F&amp;&amp;) overload
          already covers it (that&#39;s part of the entire design of
          &quot;templated rvalue references&quot;, to capture both rvalues *and*
          lvalues). Then instantiate task_object with something like
          remove_cv&lt; remove_reference&lt;F&gt;::type &gt;::type, and
          use boost::forward&lt;F&gt;(f) to pass the function object
          down to the task_object constructor.<br>
        </div>
      </div>
    </blockquote>
    Yeah, this is the point. packaged_task(F const &amp;) overload was
    not used never, and task_object  was instantiated as
    task_object&lt;R,A&amp;&gt;. I have a patch that seems to work (see
    below I have not used remove_cv yet, but I agree it should be needed
    to take care of const functors).<br></div></blockquote><div><br>Okay, now it&#39;s starting to click what you were doing before. I might&#39;ve been confusing packaged_task (where F is &quot;free&quot;) with task_object (where F is &quot;bound&quot; already). I should&#39;ve looked at it closer; sounds like you had already figured out the correct fix.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    
    The overload <br>
    <br>
            explicit packaged_task(R(*f)()):<br>
                task(new
    detail::task_object&lt;R,R(*)()&gt;(f)),future_obtained(false)<br>
            {}<br>
    <br>
    seems necessary because otherwise the task_object is instantiated
    with &lt;R,R()&gt; which is not what we want.<br>
    Do you have an hint on how simplify this?<br></div></blockquote><div><br>Okay yeah I wasn&#39;t sure why you needed this overload, thanks for clarifying. I guess when constructing a packaged_task with a function name, and you don&#39;t explicitly use the address-of operator (&amp;), F gets bound as a function reference? Probably easiest to just explicitly use a separate constructor as above and document its necessity.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    <blockquote type="cite">
      <div class="gmail_quote">
        <div>
          <br>
        </div>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> The test
            futures/packaged_task/alloc_ctor_pass.cpp gives this
            context.<br>
            <br>
            Thanks for your patience and perseverance.<br>
          </div>
        </blockquote>
        <div><br>
          And thank you for clarifying the issue for me!<br>
          <br>
        </div>
        <br>
      </div>
    </blockquote>
    Please, could you check the patch and see if there is something that
    can be improved.<br></div></blockquote><div><br>Yeah that looks about what I would&#39;ve suggested. Just add, like you said, the remove_cv&#39;s.<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
    
    Thanks for all,<br>
    Vicente<br></div></blockquote><div><br>[snip patch] <br></div><div><br>Sorry for the noise, thanks for being patient,<br><br>- Jeff<br><br></div></div>

