Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is because of the generic binding facility in terms of which the C++11 Standard defines not only how a thread is started, but also how <code>std::bind</code> and <code>std::function</code> work.</p> <p>In fact, Paragraph 30.3.1.2/3 of the C++11 Standard specifies about the variadic constructor of class <code>std::thread</code>:</p> <blockquote> <p><code>template &lt;class F, class ...Args&gt; explicit thread(F&amp;&amp; f, Args&amp;&amp;... args);</code></p> <p><em>Effects</em>: Constructs an object of type thread. The new thread of execution executes <strong><code>INVOKE (DECAY_- COPY ( std::forward&lt;F&gt;(f)), DECAY_COPY (std::forward&lt;Args&gt;(args))...)</code></strong> with the calls to <code>DECAY_COPY</code> being evaluated in the constructing thread. Any return value from this invocation is ignored. [...]</p> </blockquote> <p>Ignoring what <code>DECAY_COPY</code> does (it is not relevant to the question), this is how Paragraph 20.8.2 defines the <code>INVOKE</code> pseudo-function:</p> <blockquote> <p>Define <strong>INVOKE (f, t1, t2, ..., tN)</strong> as follows:</p> <p>— (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T;</p> <p>— ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of the types described in the previous item;</p> <p>— t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T;</p> <p>— <strong>(*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 is not one of the types described in the previous item;</strong></p> <p>— f(t1, t2, ..., tN) in all other cases.</p> </blockquote> <p>Now the question becomes: </p> <blockquote> <p>Why does the C++11 Standard defines the <code>INVOKE</code> facility that way?</p> </blockquote> <p>And the answer is <strong><a href="https://stackoverflow.com/questions/12638393/why-does-invoke-facility-in-the-c11-standard-refer-to-data-members">here</a></strong>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload