Compare commits

...

81 Commits

Author SHA1 Message Date
Peter Dimov
1480db5679 Merge branch 'develop' 2014-02-05 05:22:20 +02:00
Peter Dimov
f53694ef25 Merge branch 'develop' of https://github.com/boostorg/bind into develop 2013-12-18 19:04:20 +02:00
Peter Dimov
0afd49b884 Merge pull request #3 from danieljames/develop
Link to compose in old version of boost.
2013-12-16 15:03:04 -08:00
Daniel James
dd67e3f785 Link to compose from old version of boost.
Compose isn't included in modular boost, so there's nothing to link to.
I changed it to link to an old version which still has compose
documentation. It might be better to rewrite it?
2013-12-15 17:27:54 +00:00
Peter Dimov
c92a49d5c2 Merge commit 'f7e101e928c745199436374f944f0438b97dee28' into develop 2013-12-12 02:57:54 +02:00
Peter Dimov
a6b17d9001 Switch to BOOST_STATIC_ASSERT in arg.hpp per the patch in #8844. 2013-12-12 00:12:56 +02:00
Peter Dimov
ea05f23163 Fixed mem_fn_eq_test to work with /OPT:ICF as per the patch in #8734 by Mike Liang. 2013-12-11 23:58:19 +02:00
Peter Dimov
fafb6bb650 Merge branch 'topic/silence_warning' of https://github.com/timblechmann/bind into develop 2013-12-07 19:10:42 +02:00
Peter Dimov
f7e101e928 Merge branch 'develop' 2013-12-07 19:05:57 +02:00
Peter Dimov
166c4b6be7 Merge from master to create a merge point. 2013-12-07 19:03:34 +02:00
Peter Dimov
8414233b9c Revert "Bind: Remove obsolete MSVC version check"
This reverts commit 9955139c65.
2013-12-07 18:54:00 +02:00
Peter Dimov
15d6d6ac95 Revert "Remove obsolete MSVC check from pragma guard"
This reverts commit 5e2fc717f0.
2013-12-07 18:53:27 +02:00
Peter Dimov
ba117db120 Revert "Bind: Remove obsolete GCC version check."
This reverts commit 5b2cf44de5.
2013-12-07 18:53:01 +02:00
Peter Dimov
f5c95610b6 Revert "Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit af136e483d.
2013-12-07 18:52:39 +02:00
Peter Dimov
ce0fc0f69a Revert "Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit 0f66412487.
2013-12-07 18:51:53 +02:00
Peter Dimov
aa8a94273d Revert "Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION"
This reverts commit 7ff6524bd1.
2013-12-07 18:50:56 +02:00
Tim Blechmann
92ff08b873 bind: silence warning with gcc 2013-12-07 14:37:28 +01:00
Michel Morin
6315df35d6 Merge r86524 (Correct broken links to C++ standard papers); fixes #9212
[SVN r86673]
2013-11-13 03:22:55 +00:00
Michel Morin
96fd1e7036 Correct broken links to C++ standard papers. Refs #9212.
[SVN r86524]
2013-10-30 12:51:24 +00:00
Stephen Kelly
7ff6524bd1 Remove remaining occurances of BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
These evaded scripting.

[SVN r86249]
2013-10-11 23:22:36 +00:00
Stephen Kelly
0f66412487 Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
[SVN r86248]
2013-10-11 23:20:59 +00:00
Stephen Kelly
af136e483d Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Process #ifndef...#endif conditions.

[SVN r86244]
2013-10-11 23:15:00 +00:00
Stephen Kelly
5b2cf44de5 Bind: Remove obsolete GCC version check.
[SVN r86106]
2013-10-01 08:42:35 +00:00
Stephen Kelly
5e2fc717f0 Remove obsolete MSVC check from pragma guard
git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq

is now clean.

[SVN r85952]
2013-09-26 13:02:51 +00:00
Stephen Kelly
9955139c65 Bind: Remove obsolete MSVC version check
[SVN r85938]
2013-09-26 09:42:51 +00:00
Peter Dimov
fa8debfc80 Merge [75391] to release. Fixes #5792.
[SVN r75755]
2011-11-30 17:53:38 +00:00
Peter Dimov
da3580cc14 Apply suggested IBM C++ fix. Refs #5792.
[SVN r75391]
2011-11-07 18:25:33 +00:00
Bryce Adelstein-Lelbach
27003baf12 Pathscale-4.0 configuration code/workarounds.
[SVN r68142]
2011-01-14 02:59:34 +00:00
Marshall Clow
c53ba15ce5 Merge doc fix to release; fixes #4532
[SVN r67047]
2010-12-05 22:18:05 +00:00
Marshall Clow
3d60d74ff0 Doc patch; refs #4532
[SVN r66973]
2010-12-02 13:17:09 +00:00
Peter Dimov
7b89dd7fd9 Merge [62251] to release. Fixes #4172.
[SVN r63828]
2010-07-10 21:26:25 +00:00
Daniel James
787d3cb7b4 Merge documentation fixes.
* Use `doc/src/*.css` instead of `doc/html/*.css`.
* Remove wiki and people directories.
* Some documentation fixes.
* Left out `minimal.css` changes and boostbook changes because of clashes.


[SVN r63347]
2010-06-26 12:30:09 +00:00
Daniel James
f89c41dc7b Update various libraries' documentation build.
Mostly to use the images and css files under doc/src instead of
doc/html, usually be deleting the settings in order to use the defaults.
Also add 'boost.root' to some builds in order to fix links which rely on
it.

[SVN r63146]
2010-06-20 18:00:48 +00:00
Peter Dimov
7aa58cf653 Fix version check, as g++ 4.1 still has the PCH bug. Refs #4172.
[SVN r62251]
2010-05-26 19:34:10 +00:00
Peter Dimov
6e208277e3 Merge [58073], [58093] to release. Fixes #3003.
[SVN r58119]
2009-12-03 17:44:37 +00:00
Peter Dimov
1bf8cd6c7a Fix Borland regression. Refs #3003.
[SVN r58093]
2009-12-02 10:47:01 +00:00
Peter Dimov
e5d99ce085 Make mem_fn work with overloaded unary operator&. Refs #3003. Sorry it took so long.
[SVN r58073]
2009-12-01 02:24:53 +00:00
Peter Dimov
70f0c8efbb Merge [57954], [57955] to release.
[SVN r58066]
2009-11-30 20:30:22 +00:00
Peter Dimov
00b3c895fd Merge [57542] to release. Fixes #3601.
[SVN r57961]
2009-11-26 22:16:17 +00:00
Peter Dimov
17282c97c2 Extend Borland workaround to 6.2 and above.
[SVN r57954]
2009-11-26 21:02:04 +00:00
John Maddock
f02b090fe8 Warning suppressions in Boost.Bind.
Fixes #3601.

[SVN r57542]
2009-11-10 13:26:43 +00:00
Troy D. Straszheim
f3da835e0b rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
Troy D. Straszheim
73fc778b61 Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
Steven Watanabe
26ee2825fe Make protect use the same approximation of perfect forwarding as plain bind.
[SVN r54385]
2009-06-26 22:31:15 +00:00
Frank Mori Hess
dc1e4dbfae Use static boost::arg placeholders for gcc 4.0.1, since it has
a bug that prevents forwarding placeholders as const references
when using the static inline function placeholders.


[SVN r52384]
2009-04-14 13:45:59 +00:00
Peter Dimov
45a1f1434b Add ref_compare for weak_ptr. Refs #2849.
[SVN r51979]
2009-03-26 00:43:14 +00:00
Peter Dimov
bc50ab0ba3 Refs #2128 (fixed in trunk.)
[SVN r51512]
2009-03-01 17:04:14 +00:00
Peter Dimov
010349ec9b Refs #2127 (fixed in trunk).
[SVN r51511]
2009-03-01 16:31:53 +00:00
Peter Dimov
8ae9e8460d Borland 6.10 still needs the workaround; fails bind_dm_test without it.
[SVN r51510]
2009-03-01 16:06:44 +00:00
Peter Dimov
5d49fb45d0 Make bind.hpp and mem_fn.hpp forward to bind/bind.hpp and bind/mem_fn.hpp. (Ref #2238)
[SVN r51489]
2009-02-28 21:40:27 +00:00
Peter Dimov
4000680b6a Copy mem_fn.hpp to bind/
[SVN r51488]
2009-02-28 21:27:51 +00:00
Peter Dimov
851903fcc4 Copy bind.hpp into bind/
[SVN r51487]
2009-02-28 21:26:59 +00:00
John Maddock
1d79533df7 Add PDF generation options to fix external links to point to the web site.
Added a few more Boostbook based libs that were missed first time around.
Fixed PDF naming issues.

[SVN r51284]
2009-02-17 10:05:58 +00:00
Michael A. Jackson
f09a7a5747 Updating dependency information for modularized libraries.
[SVN r49628]
2008-11-07 17:05:27 +00:00
Michael A. Jackson
0b72bfbd9b Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
Michael A. Jackson
61519fcae2 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
Peter Dimov
48c5a6e682 Fix #2245.
[SVN r48840]
2008-09-17 23:07:33 +00:00
Ronald Garcia
1b292ee487 For building the ref docs stand-alone.
[SVN r47690]
2008-07-22 14:58:14 +00:00
Ronald Garcia
0dd5dae4e8 Added documentation for unwrap_ref.
[SVN r47689]
2008-07-22 14:55:05 +00:00
Peter Dimov
203ca82ef2 bind( type<R>(), f, ... ) now works when f is a member function.
[SVN r45619]
2008-05-21 19:49:47 +00:00
Peter Dimov
037a4d1976 Add ref_fn_test.cpp per #1846.
[SVN r44704]
2008-04-21 21:29:28 +00:00
Peter Dimov
dfd3da2cc4 Fix #1643.
[SVN r43323]
2008-02-19 15:40:58 +00:00
Peter Dimov
aef08dd0cd Fix #1642.
[SVN r43321]
2008-02-19 15:09:10 +00:00
Peter Dimov
ef993c777a Fix #1646.
[SVN r43320]
2008-02-19 14:59:28 +00:00
Peter Dimov
f58543ac11 Fix #1641.
[SVN r43319]
2008-02-19 14:51:10 +00:00
Peter Dimov
f1afd17717 Added support for &&, ||
[SVN r43269]
2008-02-15 18:40:36 +00:00
Markus Schöpflin
e73f08edee Modified spelling of my surname to avoid problems with non-ASCII characters.
[SVN r42436]
2008-01-03 10:04:39 +00:00
Vladimir Prus
3c24cbedf6 Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
Peter Dimov
79f8680eda Fix #997
[SVN r38165]
2007-07-07 17:41:54 +00:00
Peter Dimov
e163aeb563 Use object placeholders for g++ 4.1+, reported and PCH-tested by Daniel Walker
[SVN r38164]
2007-07-07 17:22:26 +00:00
Peter Dimov
ce24d4f735 Fixed to compile
[SVN r37357]
2007-04-04 21:30:32 +00:00
Peter Dimov
41d9fbc317 License update
[SVN r35988]
2006-11-10 18:27:05 +00:00
Peter Dimov
2f595f53f5 License/copyright edits
[SVN r35954]
2006-11-09 19:29:42 +00:00
Beman Dawes
c746cf26de Add copyright, license
[SVN r35905]
2006-11-07 19:11:57 +00:00
Peter Dimov
a695360c4f Borland fix
[SVN r35661]
2006-10-18 17:36:50 +00:00
Peter Dimov
0aadd1805d Rvalue overloads (suggested by Herve Bronnimann)
[SVN r35640]
2006-10-16 19:11:29 +00:00
Douglas Gregor
0cc198acc2 Work around ADL bug in GCC 3.3 that is causing failures in the Signals library
[SVN r35224]
2006-09-20 13:07:20 +00:00
Peter Dimov
b272145f3e Moved the specialization into namespace boost
[SVN r34477]
2006-07-07 19:09:16 +00:00
Peter Dimov
bfe10df38a is_placeholder, is_bind_expression added.
[SVN r34468]
2006-07-06 13:47:26 +00:00
Peter Dimov
c69a4ad382 Fixed a visit_each-related bug exposed by strict two-phase lookup
[SVN r33761]
2006-04-21 13:14:58 +00:00
Peter Dimov
683d699e4a Added diagnostic output.
[SVN r33754]
2006-04-21 11:55:39 +00:00
13 changed files with 728 additions and 84 deletions

View File

@@ -61,6 +61,7 @@
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_modeling_stl_function_object_concepts">Modeling STL function object concepts</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>
@@ -271,7 +272,7 @@ bind(&amp;X::f, p, _1)(i); // (<i>internal copy of p</i>)-&gt;f(i)
</p>
<P>This feature of <b>bind</b> can be used to perform function composition. See <A href="bind_as_compose.cpp">
bind_as_compose.cpp</A> for an example that demonstrates how to use <b>bind</b>
to achieve similar functionality to <A href="../compose/index.htm">Boost.Compose</A>.
to achieve similar functionality to <A href="http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm">Boost.Compose</A>.
</P>
<p>Note that the first argument - the bound function object - is not evaluated,
even when it's a function object that is produced by <STRONG>bind</STRONG> or a
@@ -389,7 +390,7 @@ void connect()
<p>As a general rule, the function objects generated by <b>bind</b> take their
arguments by reference and cannot, therefore, accept non-const temporaries or
literal constants. This is an inherent limitation of the C++ language in its
current (2003) incarnation, known as <A href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
current (2003) incarnation, known as <A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm">
the forwarding problem</A>. (It will be fixed in the next standard, usually
called C++0x.)</p>
<p>The library uses signatures of the form
@@ -585,6 +586,48 @@ int main()
boost::bind( get, _1 );
}
</pre>
<h3><a name="err_modeling_stl_function_object_concepts">Modeling STL function object concepts</a></h3>
<p>The function objects that are produced by <b>boost::bind</b> do not model the
STL <a href="http://www.sgi.com/tech/stl/UnaryFunction.html">Unary Function</a> or
<a href="http://www.sgi.com/tech/stl/BinaryFunction.html">Binary Function</a> concepts,
even when the function objects are unary or binary operations, because the function object
types are missing public typedefs <tt>result_type</tt> and <tt>argument_type</tt> or
<tt>first_argument_type</tt> and <tt>second_argument_type</tt>. In cases where these
typedefs are desirable, however, the utility function <tt>make_adaptable</tt>
can be used to adapt unary and binary function objects to these concepts. This allows
unary and binary function objects resulting from <b>boost::bind</b> to be combined with
STL templates such as <a href="http://msdn.microsoft.com/en-us/library/se0409db%28v=VS.90%29.aspx"><tt>std::unary_negate</tt></a>
and <a href="http://msdn.microsoft.com/en-us/library/833073z4%28v=VS.90%29.aspx"><tt>std::binary_negate</tt></a>.</p>
<p>The <tt>make_adaptable</tt> function is defined in &lt;<a href="../../boost/bind/make_adaptable.hpp">boost/bind/make_adaptable.hpp</a>&gt;,
which must be included explicitly in addition to &lt;boost/bind.hpp&gt;:</p>
<pre>
#include &lt;boost/bind/make_adaptable.hpp&gt;
template &lt;class R, class F&gt; <i>unspecified-type</i> make_adaptable(F f);
template&lt;class R, class A1, class F&gt; <i>unspecified-unary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class F&gt; <i>unspecified-binary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class A3, class F&gt; <i>unspecified-ternary-functional-type</i> make_adaptable(F f);
template&lt;class R, class A1, class A2, class A3, class A4, class F&gt; <i>unspecified-4-ary-functional-type</i> make_adaptable(F f);
</pre>
<p>This example shows how to use <tt>make_adaptable</tt> to make a predicate for "is not a space":</p>
<pre>typedef char char_t;
std::locale loc("");
const std::ctype&lt;char_t&gt;&amp; ct = std::use_facet&lt;std::ctype&lt;char_t&gt; &gt;(loc);
auto isntspace = std::not1( boost::make_adaptable&lt;bool, char_t&gt;( boost::bind(&amp;std::ctype&lt;char_t&gt;::is, &amp;ct, std::ctype_base::space, _1) ) );
</pre>
<p>In this example, <b>boost::bind</b> creates the "is a space" (unary) predicate.
It is then passed to <tt>make_adaptable</tt> so that a function object modeling
the Unary Function concept can be created, serving as the argument to
<a href="http://msdn.microsoft.com/en-us/library/syyszzf8%28v=VS.90%29.aspx"><tt>std::not1</tt></a>.</p>
<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:

View File

@@ -9,5 +9,6 @@ import boostbook : boostbook ;
boostbook ref-doc : ref.xml
:
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
<xsl:param>boost.root=../../../..
;

View File

@@ -21,6 +21,7 @@
#include <boost/config.hpp>
#include <boost/is_placeholder.hpp>
#include <boost/static_assert.hpp>
namespace boost
{
@@ -33,8 +34,7 @@ template< int I > struct arg
template< class T > arg( T const & /* t */ )
{
// static assert I == is_placeholder<T>::value
typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
BOOST_STATIC_ASSERT( I == is_placeholder<T>::value );
}
};

View File

@@ -207,6 +207,13 @@ public:
}
};
#ifdef BOOST_MSVC
// MSVC is bright enough to realise that the parameter rhs
// in operator==may be unused for some template argument types:
#pragma warning(push)
#pragma warning(disable:4100)
#endif
template< class A1 > class list1: private storage1< A1 >
{
private:
@@ -846,6 +853,10 @@ public:
}
};
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// bind_t
#ifndef BOOST_NO_VOID_RETURNS
@@ -1629,7 +1640,7 @@ template<class F, class A1, class A2, class A3, class A4, class A5, class A6, cl
// data member pointers
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) \
|| ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, <= 0x610 ) )
|| ( defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) ) )
template<class R, class T, class A1>
_bi::bind_t< R, _mfi::dm<R, T>, typename _bi::list_av_1<A1>::type >
@@ -1654,7 +1665,14 @@ template< class M, class T > struct add_cref< M T::*, 0 >
template< class M, class T > struct add_cref< M T::*, 1 >
{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4180)
#endif
typedef M const & type;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
};
template< class R, class T > struct add_cref< R (T::*) (), 1 >
@@ -1662,7 +1680,7 @@ template< class R, class T > struct add_cref< R (T::*) (), 1 >
typedef void type;
};
#if !( defined(__IBMCPP__) && BOOST_WORKAROUND( __IBMCPP__, BOOST_TESTED_AT(600) ) )
#if !defined(__IBMCPP__) || __IBMCPP_FUNC_CV_TMPL_ARG_DEDUCTION
template< class R, class T > struct add_cref< R (T::*) () const, 1 >
{

View File

@@ -51,14 +51,16 @@ public:
template<class U> R operator()(U & u) const
{
BOOST_MEM_FN_RETURN call(u, &u);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u) const
{
BOOST_MEM_FN_RETURN call(u, &u);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
}
#endif
@@ -109,7 +111,8 @@ public:
template<class U> R operator()(U const & u) const
{
BOOST_MEM_FN_RETURN call(u, &u);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p);
}
R operator()(T const & t) const
@@ -164,14 +167,16 @@ public:
template<class U> R operator()(U & u, A1 a1) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
}
#endif
@@ -223,7 +228,8 @@ public:
template<class U> R operator()(U const & u, A1 a1) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1);
}
R operator()(T const & t, A1 a1) const
@@ -276,14 +282,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
}
#endif
@@ -333,7 +341,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2);
}
R operator()(T const & t, A1 a1, A2 a2) const
@@ -386,14 +395,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
}
#endif
@@ -443,7 +454,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3) const
@@ -496,14 +508,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
}
#endif
@@ -553,7 +567,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4) const
@@ -606,14 +621,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
}
#endif
@@ -663,7 +680,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
@@ -716,14 +734,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
}
#endif
@@ -773,7 +793,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
@@ -826,14 +847,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
}
#endif
@@ -883,7 +906,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) const
@@ -936,14 +960,16 @@ public:
template<class U> R operator()(U & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
}
#ifdef BOOST_MEM_FN_ENABLE_CONST_OVERLOADS
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
}
#endif
@@ -998,7 +1024,8 @@ public:
template<class U> R operator()(U const & u, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const
{
BOOST_MEM_FN_RETURN call(u, &u, a1, a2, a3, a4, a5, a6, a7, a8);
U const * p = 0;
BOOST_MEM_FN_RETURN call(u, p, a1, a2, a3, a4, a5, a6, a7, a8);
}
R operator()(T const & t, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) const

View File

@@ -25,7 +25,7 @@
namespace
{
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 400)
#if defined(__BORLANDC__) || defined(__GNUC__) && (__GNUC__ < 4)
static inline boost::arg<1> _1() { return boost::arg<1>(); }
static inline boost::arg<2> _2() { return boost::arg<2>(); }
@@ -38,7 +38,7 @@ static inline boost::arg<8> _8() { return boost::arg<8>(); }
static inline boost::arg<9> _9() { return boost::arg<9>(); }
#elif defined(BOOST_MSVC) || (defined(__DECCXX_VER) && __DECCXX_VER <= 60590031) || defined(__MWERKS__) || \
defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ == 400)
defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
static boost::arg<1> _1;
static boost::arg<2> _2;

View File

@@ -1,14 +1,405 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../bind/mem_fn.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="../bind/mem_fn.html">../bind/mem_fn.html</a>.&nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
<p>&nbsp;</p>
</body>
</html>
<head>
<title>Boost: mem_fn.hpp documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="white" style="MARGIN-LEFT: 5%; MARGIN-RIGHT: 5%">
<table border="0" width="100%">
<tr>
<td width="277"><A href="../../index.htm"> <img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86" border="0"></A>
</td>
<td align="center">
<h1>mem_fn.hpp</h1>
</td>
</tr>
<tr>
<td colspan="2" height="64">&nbsp;</td>
</tr>
</table>
<h2>Contents</h2>
<h3 style="MARGIN-LEFT: 20pt"><a href="#Purpose">Purpose</a></h3>
<h3 style="MARGIN-LEFT: 20pt"><a href="#FAQ">Frequently Asked Questions</a></h3>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q1">Can <b>mem_fn</b> be used instead of the
standard <b>std::mem_fun[_ref]</b> adaptors?</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b>
with <b>mem_fn</b> in my existing code?</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q3">Does <b>mem_fn</b> work with COM methods?</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL
defined automatically?</a></h4>
<h3 style="MARGIN-LEFT: 20pt"><a href="#Interface">Interface</a></h3>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Synopsis">Synopsis</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#CommonRequirements">Common requirements</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#get_pointer">get_pointer</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#mem_fn">mem_fn</a></h4>
<h3 style="MARGIN-LEFT: 20pt"><a href="#Implementation">Implementation</a></h3>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Files">Files</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#Dependencies">Dependencies</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#NumberOfArguments">Number of Arguments</a></h4>
<h4 style="MARGIN-LEFT: 40pt"><a href="#stdcall">"__stdcall", "__cdecl" and
"__fastcall" Support</a></h4>
<h3 style="MARGIN-LEFT: 20pt"><a href="#Acknowledgements">Acknowledgements</a></h3>
<h2><a name="Purpose">Purpose</a></h2>
<p>
<b>boost::mem_fn</b> is a generalization of the standard functions <b>std::mem_fun</b>
and <b>std::mem_fun_ref</b>. It supports member function pointers with more
than one argument, and the returned function object can take a pointer, a
reference, or a smart pointer to an object instance as its first argument. <STRONG>mem_fn</STRONG>
also supports pointers to data members by treating them as functions taking no
arguments and returning a (const) reference to the member.
</p>
<p>
The purpose of <b>mem_fn</b> is twofold. First, it allows users to invoke a
member function on a container with the familiar
</p>
<pre>
std::for_each(v.begin(), v.end(), boost::mem_fn(&amp;Shape::draw));
</pre>
<p>
syntax, even when the container stores smart pointers.
</p>
<p>
Second, it can be used as a building block by library developers that want to
treat a pointer to member function as a function object. A library might define
an enhanced <b>for_each</b> algorithm with an overload of the form:
</p>
<pre>
template&lt;class It, class R, class T&gt; void for_each(It first, It last, R (T::*pmf) ())
{
std::for_each(first, last, boost::mem_fn(pmf));
}
</pre>
<p>
that will allow the convenient syntax:
</p>
<pre>
for_each(v.begin(), v.end(), &amp;Shape::draw);
</pre>
<p>
When documenting the feature, the library author will simply state:
</p>
<h4 style="MARGIN-LEFT: 20pt">template&lt;class It, class R, class T&gt; void
for_each(It first, It last, R (T::*pmf) ());</h4>
<p style="MARGIN-LEFT: 20pt">
<b>Effects:</b> equivalent to std::for_each(first, last, boost::mem_fn(pmf));
</p>
<p>
where <b>boost::mem_fn</b> can be a link to this page. See <a href="bind.html">the
documentation of <b>bind</b></a> for an example.
</p>
<p>
<b>mem_fn</b> takes one argument, a pointer to a member, and returns a function
object suitable for use with standard or user-defined algorithms:
</p>
<pre>
struct X
{
void f();
};
void g(std::vector&lt;X&gt; &amp; v)
{
std::for_each(v.begin(), v.end(), boost::mem_fn(&amp;X::f));
};
void h(std::vector&lt;X *&gt; const &amp; v)
{
std::for_each(v.begin(), v.end(), boost::mem_fn(&amp;X::f));
};
void k(std::vector&lt;boost::shared_ptr&lt;X&gt; &gt; const &amp; v)
{
std::for_each(v.begin(), v.end(), boost::mem_fn(&amp;X::f));
};
</pre>
<p>
The returned function object takes the same arguments as the input member
function plus a "flexible" first argument that represents the object instance.
</p>
<p>
When the function object is invoked with a first argument <b>x</b> that is
neither a pointer nor a reference to the appropriate class (<b>X</b> in the
example above), it uses <tt>get_pointer(x)</tt> to obtain a pointer from <b>x</b>.
Library authors can "register" their smart pointer classes by supplying an
appropriate <b>get_pointer</b> overload, allowing <b>mem_fn</b> to recognize
and support them.
</p>
<p>
[Note: <b>get_pointer</b> is not restricted to return a pointer. Any object
that can be used in a member function call expression <tt>(x-&gt;*pmf)(...)</tt>
will work.]
</p>
<p>
[Note: the library uses an unqualified call to <b>get_pointer</b>. Therefore,
it will find, through argument-dependent lookup, <b>get_pointer</b> overloads
that are defined in the same namespace as the corresponding smart pointer
class, in addition to any <b>boost::get_pointer</b> overloads.]
</p>
<p>
All function objects returned by <b>mem_fn</b> expose a <b>result_type</b> typedef
that represents the return type of the member function. For data members, <STRONG>result_type</STRONG>
is defined as the type of the member.
</p>
<h2><a name="FAQ">Frequently Asked Questions</a></h2>
<h3><a name="Q1">Can <b>mem_fn</b> be used instead of the standard <b>std::mem_fun[_ref]</b>
adaptors?</a></h3>
<p>
Yes. For simple uses, <b>mem_fn</b> provides additional functionality that the
standard adaptors do not. Complicated expressions that use <b>std::bind1st</b>, <b>std::bind2nd</b>
or <a href="http://www.boost.org/doc/libs/1_31_0/libs/compose/index.htm"><b>Boost.Compose</b></a> along with the
standard adaptors can be rewritten using <a href="bind.html"><b>boost::bind</b></a>
that automatically takes advantage of <b>mem_fn</b>.
</p>
<h3><a name="Q2">Should I replace every occurence of <b>std::mem_fun[_ref]</b> with <b>mem_fn</b>
in my existing code?</a></h3>
<p>
No, unless you have good reasons to do so. <b>mem_fn</b> is not 100% compatible
with the standard adaptors, although it comes pretty close. In particular, <b>mem_fn</b>
does not return objects of type <b>std::[const_]mem_fun[1][_ref]_t</b>, as the
standard adaptors do, and it is not possible to fully describe the type of the
first argument using the standard <b>argument_type</b> and <b>first_argument_type</b>
nested typedefs. Libraries that need adaptable function objects in order to
function might not like <b>mem_fn</b>.
</p>
<h3><a name="Q3">Does <b>mem_fn</b> work with COM methods?</a></h3>
<p>
Yes, if you <a href="#stdcall">#define BOOST_MEM_FN_ENABLE_STDCALL</a>.
</p>
<h3><a name="Q4">Why isn't BOOST_MEM_FN_ENABLE_STDCALL defined automatically?</a></h3>
<p>
Non-portable extensions, in general, should default to off to prevent vendor
lock-in. Had BOOST_MEM_FN_ENABLE_STDCALL been defined automatically, you could
have accidentally taken advantage of it without realizing that your code is,
perhaps, no longer portable. In addition, it is possible for the default
calling convention to be __stdcall, in which case enabling __stdcall support
will result in duplicate definitions.
</p>
<h2><a name="Interface">Interface</a></h2>
<h3><a name="Synopsis">Synopsis</a></h3>
<pre>
namespace boost
{
template&lt;class T&gt; T * <a href="#get_pointer_1">get_pointer</a>(T * p);
template&lt;class R, class T&gt; <i>unspecified-1</i> <a href="#mem_fn_1">mem_fn</a>(R (T::*pmf) ());
template&lt;class R, class T&gt; <i>unspecified-2</i> <a href="#mem_fn_2">mem_fn</a>(R (T::*pmf) () const);
template&lt;class R, class T&gt; <i>unspecified-2-1</i> <a href="#mem_fn_2_1">mem_fn</a>(R T::*pm);
template&lt;class R, class T, class A1&gt; <i>unspecified-3</i> <a href="#mem_fn_3">mem_fn</a>(R (T::*pmf) (A1));
template&lt;class R, class T, class A1&gt; <i>unspecified-4</i> <a href="#mem_fn_4">mem_fn</a>(R (T::*pmf) (A1) const);
template&lt;class R, class T, class A1, class A2&gt; <i>unspecified-5</i> <a href="#mem_fn_5">mem_fn</a>(R (T::*pmf) (A1, A2));
template&lt;class R, class T, class A1, class A2&gt; <i>unspecified-6</i> <a href="#mem_fn_6">mem_fn</a>(R (T::*pmf) (A1, A2) const);
// implementation defined number of additional overloads for more arguments
}
</pre>
<h3><a name="CommonRequirements">Common requirements</a></h3>
<p>
All <tt><i>unspecified-N</i></tt> types mentioned in the Synopsis are <b>CopyConstructible</b>
and <b>Assignable</b>. Their copy constructors and assignment operators do not
throw exceptions. <tt><i>unspecified-N</i>::result_type</tt> is defined as the
return type of the member function pointer passed as an argument to <b>mem_fn</b>
(<b>R</b> in the Synopsis.) <tt><i>unspecified-2-1</i>::result_type</tt> is
defined as <tt>R</tt>.
</p>
<h3><a name="get_pointer">get_pointer</a></h3>
<h4><a name="get_pointer_1">template&lt;class T&gt; T * get_pointer(T * p)</a></h4>
<blockquote>
<p>
<b>Returns:</b> <tt>p</tt>.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h3><a name="mem_fn">mem_fn</a></h3>
<h4><a name="mem_fn_1">template&lt;class R, class T&gt; <i>unspecified-1</i> mem_fn(R
(T::*pmf) ())</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is an l-value of type <STRONG>T </STRONG>
or derived, <tt>(get_pointer(t)-&gt;*pmf)()</tt> otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_2">template&lt;class R, class T&gt; <i>unspecified-2</i> mem_fn(R
(T::*pmf) () const)</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
is equivalent to <tt>(t.*pmf)()</tt> when <i>t</i> is of type <STRONG>T</STRONG>
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)-&gt;*pmf)()</tt>
otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_2_1">template&lt;class R, class T&gt; <i>unspecified-2-1</i> mem_fn(R
T::*pm)</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t)</i></tt>
is equivalent to <tt>t.*pm</tt> when <i>t</i> is of type <STRONG>T</STRONG> <EM>[const]<STRONG>
</STRONG></EM>or derived, <tt>get_pointer(t)-&gt;*pm</tt> otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_3">template&lt;class R, class T, class A1&gt; <i>unspecified-3</i> mem_fn(R
(T::*pmf) (A1))</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is an l-value of type <STRONG>T
</STRONG>or derived, <tt>(get_pointer(t)-&gt;*pmf)(a1)</tt> otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_4">template&lt;class R, class T, class A1&gt; <i>unspecified-4</i> mem_fn(R
(T::*pmf) (A1) const)</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1)</i></tt>
is equivalent to <tt>(t.*pmf)(a1)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
<EM>[const]<STRONG> </STRONG></EM>or derived, <tt>(get_pointer(t)-&gt;*pmf)(a1)</tt>
otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_5">template&lt;class R, class T, class A1, class A2&gt; <i>unspecified-5</i>
mem_fn(R (T::*pmf) (A1, A2))</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is an l-value of type <STRONG>
T</STRONG> or derived, <tt>(get_pointer(t)-&gt;*pmf)(a1, a2)</tt> otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h4><a name="mem_fn_6">template&lt;class R, class T, class A1, class A2&gt; <i>unspecified-6</i>
mem_fn(R (T::*pmf) (A1, A2) const)</a></h4>
<blockquote>
<p>
<b>Returns:</b> a function object <i>f</i> such that the expression <tt><i>f(t, a1, a2)</i></tt>
is equivalent to <tt>(t.*pmf)(a1, a2)</tt> when <i>t</i> is of type <STRONG>T</STRONG>
<EM>[const]</EM> or derived, <tt>(get_pointer(t)-&gt;*pmf)(a1, a2)</tt> otherwise.
</p>
<p>
<b>Throws:</b> Nothing.
</p>
</blockquote>
<h2><a name="Implementation">Implementation</a></h2>
<h3><a name="Files">Files</a></h3>
<ul>
<li>
<a href="../../boost/mem_fn.hpp">boost/mem_fn.hpp</a>
(main header)
<li>
<a href="../../boost/bind/mem_fn_cc.hpp">boost/bind/mem_fn_cc.hpp</a>
(used by mem_fn.hpp, do not include directly)
<li>
<a href="../../boost/bind/mem_fn_vw.hpp">boost/bind/mem_fn_vw.hpp</a>
(used by mem_fn.hpp, do not include directly)
<li>
<a href="../../boost/bind/mem_fn_template.hpp">boost/bind/mem_fn_template.hpp</a>
(used by mem_fn.hpp, do not include directly)
<li>
<a href="test/mem_fn_test.cpp">libs/bind/test/mem_fn_test.cpp</a>
(test)
<li>
<a href="test/mem_fn_derived_test.cpp">libs/bind/test/mem_fn_derived_test.cpp</a>
(test with derived objects)
<li>
<a href="test/mem_fn_fastcall_test.cpp">libs/bind/test/mem_fn_fastcall_test.cpp</a>
(test for __fastcall)
<li>
<a href="test/mem_fn_stdcall_test.cpp">libs/bind/test/mem_fn_stdcall_test.cpp</a>
(test for __stdcall)
<li>
<a href="test/mem_fn_void_test.cpp">libs/bind/test/mem_fn_void_test.cpp</a> (test
for void returns)</li>
</ul>
<h3><a name="Dependencies">Dependencies</a></h3>
<ul>
<li>
<a href="../config/config.htm">Boost.Config</a></li>
</ul>
<h3><a name="NumberOfArguments">Number of Arguments</a></h3>
<p>
This implementation supports member functions with up to eight arguments. This
is not an inherent limitation of the design, but an implementation detail.
</p>
<h3><a name="stdcall">"__stdcall", "__cdecl" and "__fastcall" Support</a></h3>
<p>
Some platforms allow several types of member functions that differ by their <b>calling
convention</b> (the rules by which the function is invoked: how are
arguments passed, how is the return value handled, and who cleans up the stack
- if any.)
</p>
<p>
For example, Windows API functions and COM interface member functions use a
calling convention known as <b>__stdcall</b>. Borland VCL components use <STRONG>__fastcall</STRONG>.
UDK, the component model of OpenOffice.org, uses <STRONG>__cdecl</STRONG>.
</p>
<p>
To use <b>mem_fn</b> with <b>__stdcall</b> member functions, <b>#define</b> the
macro <b>BOOST_MEM_FN_ENABLE_STDCALL</b> before including, directly or
indirectly, <b>&lt;boost/mem_fn.hpp&gt;</b>.
</p>
<P>To use <B>mem_fn</B> with <B>__fastcall</B> member functions, <B>#define</B> the
macro <B>BOOST_MEM_FN_ENABLE_FASTCALL</B> before including <B>&lt;boost/mem_fn.hpp&gt;</B>.
</P>
<P>To use <B>mem_fn</B> with <B>__cdecl</B> member functions, <B>#define</B> the
macro <B>BOOST_MEM_FN_ENABLE_CDECL</B> before including <B>&lt;boost/mem_fn.hpp&gt;</B>.
</P>
<P><STRONG>It is best to define these macros in the project options, via -D on the
command line, or as the first line in the translation unit (.cpp file) where
mem_fn is used.</STRONG> Not following this rule can lead to obscure errors
when a header includes mem_fn.hpp before the macro has been defined.</P>
<P>[Note: this is a non-portable extension. It is not part of the interface.]
</P>
<p>
[Note: Some compilers provide only minimal support for the <b>__stdcall</b> keyword.]
</p>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>
Rene Jager's initial suggestion of using traits classes to make <b>mem_fn</b> adapt
to user-defined smart pointers inspired the <b>get_pointer</b>-based design.
</p>
<p>
Numerous improvements were suggested during the formal review period by Richard
Crossley, Jens Maurer, Ed Brey, and others. Review manager was Darin Adler.
</p>
<p>
Steve Anichini pointed out that COM interfaces use <b>__stdcall</b>.
</p>
<p>
Dave Abrahams modified <b>bind</b> and <b>mem_fn</b> to support void returns on
deficient compilers.
</p>
<p>Daniel Boelzle pointed out that UDK uses <STRONG>__cdecl</STRONG>.<br>
<br>
<br>
<small>Copyright © 2001, 2002 by Peter Dimov and Multi Media Ltd. Copyright
2003-2005 Peter Dimov. Distributed under the Boost Software License, Version
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
</body>
</html>

View File

@@ -43,4 +43,5 @@ test-suite "bind"
[ run bind_ref_test.cpp ]
[ run bind_eq3_test.cpp ]
[ run protect_test.cpp ]
[ run mem_fn_unary_addr_test.cpp ]
;

View File

@@ -33,6 +33,12 @@
struct X
{
// SGI-related compilers have odd compiler-synthesized ctors dtors
#ifdef __PATHSCALE__
X() {}
~X() {}
#endif
int operator()()
{
return 17041;

View File

@@ -43,6 +43,11 @@ public:
{
}
// SGI-related compilers have odd compiler-synthesized ctors and dtors
#ifdef __PATHSCALE__
~X() {}
#endif
int state() const
{
return state_;

View File

@@ -5,6 +5,7 @@
# pragma warning(disable: 4710) // function not inlined
# pragma warning(disable: 4711) // function selected for automatic inline expansion
# pragma warning(disable: 4514) // unreferenced inline removed
# pragma warning(disable: 4100) // unreferenced formal parameter (it is referenced!)
#endif
// Copyright (c) 2006 Douglas Gregor <doug.gregor@gmail.com>

View File

@@ -39,128 +39,128 @@ struct X
// 0
int mf0_1() { return 0; }
int mf0_2() { return 0; }
int mf0_2() { return 1; }
int cmf0_1() const { return 0; }
int cmf0_2() const { return 0; }
int cmf0_2() const { return 1; }
void mf0v_1() {}
void mf0v_2() {}
void mf0v_2() { static int x; ++x; }
void cmf0v_1() const {}
void cmf0v_2() const {}
void cmf0v_2() const { static int x; ++x; }
// 1
int mf1_1(int) { return 0; }
int mf1_2(int) { return 0; }
int mf1_2(int) { return 1; }
int cmf1_1(int) const { return 0; }
int cmf1_2(int) const { return 0; }
int cmf1_2(int) const { return 1; }
void mf1v_1(int) {}
void mf1v_2(int) {}
void mf1v_2(int) { static int x; ++x; }
void cmf1v_1(int) const {}
void cmf1v_2(int) const {}
void cmf1v_2(int) const { static int x; ++x; }
// 2
int mf2_1(int, int) { return 0; }
int mf2_2(int, int) { return 0; }
int mf2_2(int, int) { return 1; }
int cmf2_1(int, int) const { return 0; }
int cmf2_2(int, int) const { return 0; }
int cmf2_2(int, int) const { return 1; }
void mf2v_1(int, int) {}
void mf2v_2(int, int) {}
void mf2v_2(int, int) { static int x; ++x; }
void cmf2v_1(int, int) const {}
void cmf2v_2(int, int) const {}
void cmf2v_2(int, int) const { static int x; ++x; }
// 3
int mf3_1(int, int, int) { return 0; }
int mf3_2(int, int, int) { return 0; }
int mf3_2(int, int, int) { return 1; }
int cmf3_1(int, int, int) const { return 0; }
int cmf3_2(int, int, int) const { return 0; }
int cmf3_2(int, int, int) const { return 1; }
void mf3v_1(int, int, int) {}
void mf3v_2(int, int, int) {}
void mf3v_2(int, int, int) { static int x; ++x; }
void cmf3v_1(int, int, int) const {}
void cmf3v_2(int, int, int) const {}
void cmf3v_2(int, int, int) const { static int x; ++x; }
// 4
int mf4_1(int, int, int, int) { return 0; }
int mf4_2(int, int, int, int) { return 0; }
int mf4_2(int, int, int, int) { return 1; }
int cmf4_1(int, int, int, int) const { return 0; }
int cmf4_2(int, int, int, int) const { return 0; }
int cmf4_2(int, int, int, int) const { return 1; }
void mf4v_1(int, int, int, int) {}
void mf4v_2(int, int, int, int) {}
void mf4v_2(int, int, int, int) { static int x; ++x; }
void cmf4v_1(int, int, int, int) const {}
void cmf4v_2(int, int, int, int) const {}
void cmf4v_2(int, int, int, int) const { static int x; ++x; }
// 5
int mf5_1(int, int, int, int, int) { return 0; }
int mf5_2(int, int, int, int, int) { return 0; }
int mf5_2(int, int, int, int, int) { return 1; }
int cmf5_1(int, int, int, int, int) const { return 0; }
int cmf5_2(int, int, int, int, int) const { return 0; }
int cmf5_2(int, int, int, int, int) const { return 1; }
void mf5v_1(int, int, int, int, int) {}
void mf5v_2(int, int, int, int, int) {}
void mf5v_2(int, int, int, int, int) { static int x; ++x; }
void cmf5v_1(int, int, int, int, int) const {}
void cmf5v_2(int, int, int, int, int) const {}
void cmf5v_2(int, int, int, int, int) const { static int x; ++x; }
// 6
int mf6_1(int, int, int, int, int, int) { return 0; }
int mf6_2(int, int, int, int, int, int) { return 0; }
int mf6_2(int, int, int, int, int, int) { return 1; }
int cmf6_1(int, int, int, int, int, int) const { return 0; }
int cmf6_2(int, int, int, int, int, int) const { return 0; }
int cmf6_2(int, int, int, int, int, int) const { return 1; }
void mf6v_1(int, int, int, int, int, int) {}
void mf6v_2(int, int, int, int, int, int) {}
void mf6v_2(int, int, int, int, int, int) { static int x; ++x; }
void cmf6v_1(int, int, int, int, int, int) const {}
void cmf6v_2(int, int, int, int, int, int) const {}
void cmf6v_2(int, int, int, int, int, int) const { static int x; ++x; }
// 7
int mf7_1(int, int, int, int, int, int, int) { return 0; }
int mf7_2(int, int, int, int, int, int, int) { return 0; }
int mf7_2(int, int, int, int, int, int, int) { return 1; }
int cmf7_1(int, int, int, int, int, int, int) const { return 0; }
int cmf7_2(int, int, int, int, int, int, int) const { return 0; }
int cmf7_2(int, int, int, int, int, int, int) const { return 1; }
void mf7v_1(int, int, int, int, int, int, int) {}
void mf7v_2(int, int, int, int, int, int, int) {}
void mf7v_2(int, int, int, int, int, int, int) { static int x; ++x; }
void cmf7v_1(int, int, int, int, int, int, int) const {}
void cmf7v_2(int, int, int, int, int, int, int) const {}
void cmf7v_2(int, int, int, int, int, int, int) const { static int x; ++x; }
// 8
int mf8_1(int, int, int, int, int, int, int, int) { return 0; }
int mf8_2(int, int, int, int, int, int, int, int) { return 0; }
int mf8_2(int, int, int, int, int, int, int, int) { return 1; }
int cmf8_1(int, int, int, int, int, int, int, int) const { return 0; }
int cmf8_2(int, int, int, int, int, int, int, int) const { return 0; }
int cmf8_2(int, int, int, int, int, int, int, int) const { return 1; }
void mf8v_1(int, int, int, int, int, int, int, int) {}
void mf8v_2(int, int, int, int, int, int, int, int) {}
void mf8v_2(int, int, int, int, int, int, int, int) { static int x; ++x; }
void cmf8v_1(int, int, int, int, int, int, int, int) const {}
void cmf8v_2(int, int, int, int, int, int, int, int) const {}
void cmf8v_2(int, int, int, int, int, int, int, int) const { static int x; ++x; }
};

View File

@@ -0,0 +1,151 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// mem_fn_unary_addr_test.cpp - poisoned operator& test
//
// Copyright (c) 2009 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/mem_fn.hpp>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(push, 3)
#endif
#include <iostream>
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
#pragma warning(pop)
#endif
unsigned int hash = 0;
struct X
{
int f0() { f1(17); return 0; }
int g0() const { g1(17); return 0; }
int f1(int a1) { hash = (hash * 17041 + a1) % 32768; return 0; }
int g1(int a1) const { hash = (hash * 17041 + a1 * 2) % 32768; return 0; }
int f2(int a1, int a2) { f1(a1); f1(a2); return 0; }
int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; }
int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; }
int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; }
int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; }
int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; }
int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; }
int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; }
int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; }
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; }
int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; }
int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; }
int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; }
};
template<class T> class Y
{
private:
T * pt_;
void operator& ();
void operator& () const;
public:
explicit Y( T * pt ): pt_( pt )
{
}
T * get() const
{
return pt_;
}
};
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
namespace boost
{
#endif
template<class T> T * get_pointer( Y< T > const & y )
{
return y.get();
}
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x620 ) )
} // namespace boost
#endif
int detect_errors(bool x)
{
if( x )
{
std::cerr << "no errors detected.\n";
return 0;
}
else
{
std::cerr << "test failed.\n";
return 1;
}
}
int main()
{
using boost::mem_fn;
X x;
Y<X> px( &x );
Y<X const> pcx( &x );
mem_fn(&X::f0)( px );
mem_fn(&X::g0)( pcx );
mem_fn(&X::f1)( px, 1 );
mem_fn(&X::g1)( pcx, 1 );
mem_fn(&X::f2)( px, 1, 2 );
mem_fn(&X::g2)( pcx, 1, 2 );
mem_fn(&X::f3)( px, 1, 2, 3 );
mem_fn(&X::g3)( pcx, 1, 2, 3 );
mem_fn(&X::f4)( px, 1, 2, 3, 4 );
mem_fn(&X::g4)( pcx, 1, 2, 3, 4 );
mem_fn(&X::f5)( px, 1, 2, 3, 4, 5 );
mem_fn(&X::g5)( pcx, 1, 2, 3, 4, 5 );
mem_fn(&X::f6)( px, 1, 2, 3, 4, 5, 6 );
mem_fn(&X::g6)( pcx, 1, 2, 3, 4, 5, 6 );
mem_fn(&X::f7)( px, 1, 2, 3, 4, 5, 6, 7 );
mem_fn(&X::g7)( pcx, 1, 2, 3, 4, 5, 6, 7 );
mem_fn(&X::f8)( px, 1, 2, 3, 4, 5, 6, 7, 8 );
mem_fn(&X::g8)( pcx, 1, 2, 3, 4, 5, 6, 7, 8 );
return detect_errors( hash == 2155 );
}