<div dir="ltr">Thank you for your reply!<div>And after reading the whole std::bind implementation, I've realized that std::bind could take pointer to object as well as shared_ptr/unique_ptr as it's input.</div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 11, 2014 at 12:12 AM, Marshall Clow <span dir="ltr"><<a href="mailto:mclow.lists@gmail.com" target="_blank">mclow.lists@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="h5"><br><div><div>On Jul 9, 2014, at 3:41 AM, 苏焕然 <<a href="mailto:ownesss@gmail.com" target="_blank">ownesss@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">I don't quite understand about __invoke bullet2 and bullet4.<div><br></div><div>for example, bullet2:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">template</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">class</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">_Fp</span><span style="line-height:13px;white-space:pre-wrap">,</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">class</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">_A0</span><span style="line-height:13px;white-space:pre-wrap">,</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">class</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">...</span><span style="line-height:13px;white-space:pre-wrap">_Args</span><span style="line-height:13px;white-space:pre-wrap">,<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">class</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">=</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">enable_if<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><<br></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">is_member_function_pointer</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">remove_reference</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap">_Fp</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">type</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">value</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">&&<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">!</span><span style="line-height:13px;white-space:pre-wrap">is_base_of</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">remove_reference</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">__member_pointer_traits</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">remove_reference</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap">_Fp</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">type</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">_ClassType</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">type</span><span style="line-height:13px;white-space:pre-wrap">,<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">typename</font></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">remove_reference</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap">_A0</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">type</span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">value<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">>::</span><span style="line-height:13px;white-space:pre-wrap">type<br></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">><br>
</span><span style="line-height:13px;white-space:pre-wrap">_LIBCPP_INLINE_VISIBILITY<br></span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">auto<br></font></span><span style="line-height:13px;white-space:pre-wrap">__invoke</span><span style="line-height:13px;white-space:pre-wrap">(</span><span style="line-height:13px;white-space:pre-wrap">_Fp</span><span style="line-height:13px;white-space:pre-wrap">&&</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">__f</span><span style="line-height:13px;white-space:pre-wrap">,</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">_A0</span><span style="line-height:13px;white-space:pre-wrap">&&</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">__a0</span><span style="line-height:13px;white-space:pre-wrap">,</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">_Args</span><span style="line-height:13px;white-space:pre-wrap">&&</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">...</span><span style="line-height:13px;white-space:pre-wrap">__args</span><span style="line-height:13px;white-space:pre-wrap">)<br>
</span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap">-></span><span style="line-height:13px;white-space:pre-wrap"> </span><span style="line-height:13px;white-space:pre-wrap"><font color="#9900ff">decltype</font></span><span style="line-height:13px;white-space:pre-wrap">(((*</span><span style="line-height:13px;white-space:pre-wrap">_VSTD</span><span style="line-height:13px;white-space:pre-wrap">::</span><span style="line-height:13px;white-space:pre-wrap">forward</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap">_A0</span><span style="line-height:13px;white-space:pre-wrap">>(</span><span style="line-height:13px;white-space:pre-wrap">__a0</span><span style="line-height:13px;white-space:pre-wrap">)).*</span><span style="line-height:13px;white-space:pre-wrap">__f</span><span style="line-height:13px;white-space:pre-wrap">)(</span><span style="line-height:13px;white-space:pre-wrap">_VSTD</span><span style="line-height:13px;white-space:pre-wrap">::</span><span style="line-height:13px;white-space:pre-wrap">forward</span><span style="line-height:13px;white-space:pre-wrap"><</span><span style="line-height:13px;white-space:pre-wrap">_Args</span><span style="line-height:13px;white-space:pre-wrap">>(</span><span style="line-height:13px;white-space:pre-wrap">__args</span><span style="line-height:13px;white-space:pre-wrap">)...));</span></blockquote>
<div><br></div><div>this functions invokes <b>f</b> with <b>(*a0).f(args) (</b>as written in header __functional_base)<b>, </b>so I guess that a0/A0 has the type of <i>Pointer to Class? (thus, of course, isn't a base class of himself)</i></div>
<div><br></div><div>Then why did <b>enable_if </b>just test if <i>ClassType</i> of <b>f </b>isn't a base class of <b>A0 </b>?</div><div>wouldn't </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
&& is_base_of<member_pointer_traits<_Fp>::ClassType, remove_pointer<A0>>::value</blockquote><div><br></div><div>be more accurate? also, wouldn't <Some_Class_C::*Fp, Some_Class_D, Some_Args...> makes the value of enable_if to be <font color="#9900ff">true</font>?</div>
<div><br></div><div>I must guess that there is something I hadn't taken into consideration ;> </div></div></blockquote><br></div></div></div><div>The enable_if conditions are taken directly from the description in the standard (using N3936 here), 20.9.2/1:</div>
<div><br></div><div><span style="white-space:pre-wrap"> </span>Define INVOKE (f, t1, t2, ..., tN) as follows:</div><div><br><span style="white-space:pre-wrap"> </span>— (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of<br>
type T or a reference to an object of type T or a reference to an object of a type derived from T;<br><br></div><div><span style="white-space:pre-wrap"> </span>— ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of<br>
the types described in the previous item;</div><br><div><div><span style="white-space:pre-wrap"> </span>— Bullet #3 elided</div></div><div><div><span style="white-space:pre-wrap"> </span>— Bullet #4 elided</div></div><div>
<div><span style="white-space:pre-wrap"> </span>— Bullet #5 elided</div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>— Marshall</div><div><br></div></font></span></div></blockquote></div><br></div>