1
0
forked from boostorg/bind
[SVN r43323]
This commit is contained in:
Peter Dimov
2008-02-19 15:40:58 +00:00
parent aef08dd0cd
commit dfd3da2cc4

View File

@@ -60,6 +60,7 @@
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_long_form">Inappropriate use of
bind&lt;R&gt;(f, ...)</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_nonstd">Binding a nonstandard function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_overloaded">Binding an overloaded function</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_const_arg"><b>const</b> in signatures</A></h4>
<h4 style="MARGIN-LEFT: 40pt"><A href="#err_msvc_using">MSVC specific: using
boost::bind;</A></h4>
@@ -553,6 +554,37 @@ int main()
recognized by the short form of bind.
</p>
<P>See also <A href="#stdcall">"__stdcall" and "pascal" Support</A>.</P>
<h3><a name="err_overloaded">Binding an overloaded function</a></h3>
<p>An attempt to bind an overloaded function usually results in an error, as there
is no way to tell which overload was meant to be bound. This is a common
problem with member functions with two overloads, const and non-const, as in
this simplified example:</p>
<pre>struct X
{
int&amp; get();
int const&amp; get() const;
};
int main()
{
boost::bind( &amp;X::get, _1 );
}
</pre>
<P>The ambiguity can be resolved manually by casting the (member) function pointer
to the desired type:</P>
<pre>int main()
{
boost::bind( static_cast&lt; int const&amp; (X::*) () const &gt;( &amp;X::get ), _1 );
}
</pre>
<P>Another, arguably more readable, alternative is to introduce a temporary
variable:</P>
<pre>int main()
{
int const&amp; (X::*get) () const = &amp;X::get;
boost::bind( get, _1 );
}
</pre>
<h3><a name="err_const_arg"><b>const</b> in signatures</a></h3>
<p>Some compilers, including MSVC 6.0 and Borland C++ 5.5.1, have problems with the
top-level <b>const</b> in function signatures: