mirror of
https://github.com/boostorg/function.git
synced 2025-06-25 20:11:37 +02:00
Compare commits
5 Commits
feature/re
...
boost-1.29
Author | SHA1 | Date | |
---|---|---|---|
7c560d1d5a | |||
0c34bf4fb4 | |||
eb234b3e66 | |||
4482f886f1 | |||
cd9f10006b |
@ -5,7 +5,7 @@
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080">
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86">boost::function Frequently Asked Questions</h1>
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86" alt="C++ Boost">boost::function Frequently Asked Questions</h1>
|
||||
|
||||
<h2>Q: I see void pointers; is this [mess] type safe?</h2>
|
||||
<p>Yes, <code>boost::function</code> is type safe even though it uses void pointers and pointers to functions returning void and taking no arguments. Essentially, all type information is encoded in the functions that manage and invoke function pointers and function objects. Only these functions are instantiated with the exact type that is pointed to by the void pointer or pointer to void function. The reason that both are required is that one may cast between void pointers and object pointers safely or between different types of function pointers (provided you don't invoke a function pointer with the wrong type).
|
||||
@ -21,7 +21,7 @@ void g() { return f(); }
|
||||
<pre>
|
||||
int do_something(int);
|
||||
|
||||
boost::function<void, int> f;
|
||||
boost::function<void, int> f;
|
||||
f = do_something;
|
||||
</pre>
|
||||
<p> This is a valid usage of <code>boost::function</code> because void returns are not used. With void returns, we would attempting to compile ill-formed code similar to:
|
||||
@ -35,10 +35,10 @@ void g() { return f(); }
|
||||
<p> In November and December of 2000, the issue of cloning vs. reference counting was debated at length and it was decided that cloning gave more predictable semantics. I won't rehash the discussion here, but if it cloning is incorrect for a particular application a reference-counting allocator could be used.
|
||||
|
||||
<hr>
|
||||
<address><a href="mailto:gregod@cs.rpi.edu">Doug Gregor</a></address>
|
||||
<address><a href="http://www.cs.rpi.edu/~gregod">Doug Gregor</a></address>
|
||||
<!-- Created: Fri Feb 16 09:30:41 EST 2001 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Nov 7 15:11:52 EST 2001
|
||||
Last modified: Fri Oct 11 05:39:27 EDT 2002
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
@ -6,9 +6,9 @@
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080">
|
||||
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86">Boost.Function Reference Manual</h1>
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86" alt="C++ Boost">Boost.Function Reference Manual</h1>
|
||||
|
||||
<h2><a name="header">Header <code><<a href="../../../boost/function.hpp">boost/function.hpp</a>></code> synopsis</a></h2>
|
||||
<h2><a name="header">Header</a> <code><<a href="../../../boost/function.hpp">boost/function.hpp</a>></code> synopsis</h2>
|
||||
<p> Here <code><i>MAX_ARGS</i></code> is an implementation-defined constant that defines the maximum number of function arguments supported by Boost.Function and will be at least 10. The <code><i>MAX_ARGS</i></code> constant referred to in this document need not have any direct representation in the library.
|
||||
|
||||
<pre>
|
||||
@ -84,7 +84,7 @@
|
||||
function<em>N</em><ResultType, Arg1, Arg2, <i>...</i>, Arg<i>N</i>, Policy, Mixin, Allocator><b>&</b>);
|
||||
|
||||
// For any <i>N</i> in [0, <i>MAX_ARGS</i>]
|
||||
<b>template</b><<b>typename</b> Signature, <em>// Function type: ResultType (Arg1, Arg2, ..., Arg<em>N</em>)</em>
|
||||
<b>template</b><<b>typename</b> Signature, <em>// Function type: ResultType (Arg1, Arg2, ..., ArgN)</em>
|
||||
<b>typename</b> Policy = empty_function_policy, <em>// Deprecated</em>
|
||||
<b>typename</b> Mixin = empty_function_mixin, <em>// Deprecated</em>
|
||||
<b>typename</b> Allocator = std::allocator<function_base> >
|
||||
@ -112,7 +112,6 @@
|
||||
</pre>
|
||||
|
||||
<h2>Definitions</h2>
|
||||
<p>
|
||||
<ul>
|
||||
<li><a name="compatible"></a>A function object <code>f</code> is <em>compatible</em> if for the given set of argument types <code>Arg1</code>, <code>Arg2</code>, ..., <code>Arg<em>N</em></code> and a return type <code>ResultType</code>, the appropriate following function is well-formed:
|
||||
<pre>
|
||||
@ -172,7 +171,7 @@
|
||||
<li><b>Throws</b>: will not throw when <code>g</code> is a <a href="#stateless">stateless</a> function object unless construction of the <code>Mixin</code> subobject throws.</li>
|
||||
</ul>
|
||||
|
||||
<p> <a name="functionN_target_ref"><code><b>template</b><<b>typename</b> F> function<i>N</i>(<a href="../../bind/ref.html">reference_wrapper</a><F> g);</code></a>
|
||||
<p> <a name="functionN_target_ref"></a><code><b>template</b><<b>typename</b> F> function<i>N</i>(<a href="../../bind/ref.html">reference_wrapper</a><F> g);</code>
|
||||
<ul>
|
||||
<li><b>Requires</b>: <code>g.get()</code> is a <a href="#compatible">compatible</a> function object.</li>
|
||||
<li><b>Effects</b>: Constructs the <code>Mixin</code> subobject from the given mixin.</li>
|
||||
@ -195,7 +194,7 @@
|
||||
<li><b>Throws</b>: will not throw when <code>g</code> is a <a href="#stateless">stateless</a> function object.</li>
|
||||
</ul>
|
||||
|
||||
<p> <a name="functionN_target_ref_assn"><code><b>template</b><<b>typename</b> F> function<i>N</i><b>&</b> <b>operator</b>=(<a href="../../bind/ref.html">reference_wrapper</a><F> g);</code></a>
|
||||
<p> <a name="functionN_target_ref_assn"></a><code><b>template</b><<b>typename</b> F> function<i>N</i><b>&</b> <b>operator</b>=(<a href="../../bind/ref.html">reference_wrapper</a><F> g);</code>
|
||||
<ul>
|
||||
<li><b>Requires</b>: <code>g.get()</code> is a <a href="#compatible">compatible</a> function object.</li>
|
||||
<li><b>Postconditions</b>: <code>f</code> targets <code>g.get()</code> (not a copy of <code>g.get()</code>) if <code>g.get()</code> is nonempty, or <code>f.<a href="#empty">empty</a>()</code> if <code>g.get()</code> is empty.</li>
|
||||
@ -260,7 +259,6 @@
|
||||
<p> The semantics of all operations in class template <code>function</code> are equivalent to that of the underlying <code>function<i>N</i></code> object, although additional member functions are required to allow proper copy construction and copy assignment of <code>function</code> objects.
|
||||
|
||||
<h2><a name="operations">Operations</a></h2>
|
||||
<p>
|
||||
<pre>
|
||||
<b>template</b><<b>typename</b> ResultType,
|
||||
<b>typename</b> Arg1,
|
||||
@ -277,7 +275,6 @@
|
||||
<li><b>Effects</b>: <code>f.<a href="#functionN_swap">swap</a>(g);</code></li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<pre>
|
||||
<b>template</b><<b>typename</b> Signature, <b>typename</b> Policy, <b>typename</b> Mixin, <b>typename</b> Allocator>
|
||||
<b>void</b> <a name="swap_function">swap</a>(function<Signature, Policy, Mixin, Allocator><b>&</b> f,
|
||||
@ -290,10 +287,10 @@
|
||||
<hr>
|
||||
<p><a name="novoid">[1]</a> On compilers not supporting void returns, when the <code>ReturnType</code> is <b>void</b>, the <code>result_type</code> of a Boost.Function object is implementation-defined.
|
||||
<hr>
|
||||
<address><a href="mailto:gregod@cs.rpi.edu">Douglas Gregor</a></address>
|
||||
<address><a href="http://www.cs.rpi.edu/~gregod">Doug Gregor</a></address>
|
||||
<!-- Created: Fri Jul 13 10:57:20 EDT 2001 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Fri Sep 6 14:46:50 EDT 2002
|
||||
Last modified: Fri Oct 11 05:40:09 EDT 2002
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
|
@ -6,17 +6,17 @@
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080">
|
||||
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86">Boost.Function Tutorial</h1>
|
||||
<h1><IMG SRC="../../../c++boost.gif" WIDTH="276" HEIGHT="86" alt="C++ Boost">Boost.Function Tutorial</h1>
|
||||
|
||||
<p> Boost.Function has two syntactical forms: the preferred form and the compatibility form. The preferred form fits more closely with the C++ language and reduces the number of separate template parameters that need to be considered, often improving readability; however, the preferred form is not supported on all platforms due to compiler bugs. The compatible form will work on all compilers supported by Boost.Function. Consult the table below to determine which syntactic form to use for your compiler.
|
||||
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="Compilers support for Boost.Function syntactic constructs">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<ul>
|
||||
<li>GNU C++ 2.95.x, 3.0.x, 3.1.x</li>
|
||||
<li>GNU C++ 2.95.x, 3.0.x, 3.1.x, 3.2</li>
|
||||
<li>Comeau C++ 4.2.45.2</li>
|
||||
<li>SGI MIPSpro 7.3.0</li>
|
||||
<li>Intel C++ 5.0, 6.0</li>
|
||||
@ -37,10 +37,10 @@
|
||||
|
||||
<p> If your compiler does not appear in this list, please try the preferred syntax and report your results to the Boost list so that we can keep this table up-to-date.
|
||||
|
||||
<a name="preferred"><h2>Basic Usage</h2></a>
|
||||
<h2><a name="preferred">Basic Usage</a></h2>
|
||||
<p> A function wrapper is defined simply by instantiating the <code>function</code> class template with the desired return type and argument types, formulated as a C++ function type. Any number of arguments may be supplied, up to some implementation-defined limit (10 is the default maximum). The following declares a function object wrapper <code>f</code> that takes two <code>int</code> parameters and returns a <code>float</code>:
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="Declaring Boost.Function objects">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -77,7 +77,7 @@ std::cout << f(5, 3) >> std::endl;
|
||||
<p> We are free to assign any compatible function object to <code>f</code>. If <code>int_div</code> had been declared to take two <code>long</code> operands,
|
||||
the implicit conversions would have been applied to the arguments without any user interference. The only limit on the types of arguments is that they be CopyConstructible, so we can even use references and arrays:
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="Declaring a more complex Boost.Function object">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -95,7 +95,7 @@ boost::function4<void, int[], int, int&, float> sum_avg;
|
||||
</center>
|
||||
|
||||
<pre>
|
||||
void do_sum_avg(int values[], int n, int& sum, float& avg)
|
||||
void do_sum_avg(int values[], int n, int& sum, float& avg)
|
||||
{
|
||||
sum = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
@ -125,13 +125,12 @@ else
|
||||
|
||||
<p> Note that the <code>&</code> isn't really necessary unless you happen to be using Microsoft Visual C++ version 6.
|
||||
|
||||
<h3>Member functions</h3>
|
||||
<a name="member_func">
|
||||
<h3><a name="member_func">Member functions</a></h3>
|
||||
<p> In many systems, callbacks often call to member functions of a particular
|
||||
object. This is often referred to as "argument binding", and is beyond the scope of Boost.Function. The use of member functions directly, however, is supported, so the following code is valid:
|
||||
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="Member functions and Boost.Function">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -172,7 +171,7 @@ f(&x, 5);
|
||||
|
||||
<li> The C++ Standard library. Using <code>std::bind1st</code> and <code>std::mem_fun</code> together one can bind the object of a pointer-to-member function for use with Boost.Function:
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="Boost.Bind and Boost.Function">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -216,7 +215,7 @@ href="../../bind/ref.html"><code>ref</code></a> and <a
|
||||
href="../../bind/ref.html"><code>cref</code></a> functions to wrap a
|
||||
reference to a function object:
|
||||
<center>
|
||||
<table border=1 cellspacing=1>
|
||||
<table border=1 cellspacing=1 summary="ref and cref with Boost.Function">
|
||||
<tr><th bgcolor="#008080">Preferred Syntax</th><th bgcolor="#008080">Compatible Syntax</th></tr>
|
||||
<tr>
|
||||
<td>
|
||||
@ -249,10 +248,10 @@ function objects, Boost.Function will not throw exceptions during
|
||||
assignment or construction.
|
||||
|
||||
<hr>
|
||||
<address><a href="mailto:gregod@cs.rpi.edu">Douglas Gregor</a></address>
|
||||
<address><a href="http://www.cs.rpi.edu/~gregod">Doug Gregor</a></address>
|
||||
<!-- Created: Fri Jul 13 12:47:11 EDT 2001 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Mon Aug 5 11:07:17 EDT 2002
|
||||
Last modified: Fri Oct 11 05:40:00 EDT 2002
|
||||
<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,15 +10,24 @@
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
|
||||
// William Kempf, Jesse Jones and Karl Nelson were all very helpful in the
|
||||
// design of this library.
|
||||
|
||||
#ifndef BOOST_FUNCTION_HPP
|
||||
#define BOOST_FUNCTION_HPP
|
||||
|
||||
#if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
|
||||
// Work around a compiler bug.
|
||||
// boost::python::detail::function has to be seen by the compiler before the
|
||||
// boost::function class template.
|
||||
namespace boost { namespace python { namespace detail {
|
||||
class function;
|
||||
}}}
|
||||
#endif
|
||||
|
||||
#include <boost/function/function_base.hpp>
|
||||
#include <boost/type_traits/function_traits.hpp>
|
||||
#include <boost/type_traits/same_traits.hpp>
|
||||
@ -51,7 +60,7 @@ namespace boost {
|
||||
struct real_get_function_impl<0>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -70,9 +79,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function0<R,
|
||||
typedef function0<R,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -82,7 +91,7 @@ namespace boost {
|
||||
struct real_get_function_impl<1>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -101,9 +110,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function1<R, T1,
|
||||
typedef function1<R, T1,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -113,7 +122,7 @@ namespace boost {
|
||||
struct real_get_function_impl<2>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -132,9 +141,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function2<R, T1, T2,
|
||||
typedef function2<R, T1, T2,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -144,7 +153,7 @@ namespace boost {
|
||||
struct real_get_function_impl<3>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -163,9 +172,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function3<R, T1, T2, T3,
|
||||
typedef function3<R, T1, T2, T3,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -175,7 +184,7 @@ namespace boost {
|
||||
struct real_get_function_impl<4>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -194,9 +203,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function4<R, T1, T2, T3, T4,
|
||||
typedef function4<R, T1, T2, T3, T4,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -206,7 +215,7 @@ namespace boost {
|
||||
struct real_get_function_impl<5>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -225,11 +234,11 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function5<R, T1, T2, T3, T4, T5,
|
||||
typedef function5<R, T1, T2, T3, T4, T5,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator>
|
||||
Allocator>
|
||||
type;
|
||||
};
|
||||
};
|
||||
@ -238,7 +247,7 @@ namespace boost {
|
||||
struct real_get_function_impl<6>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -257,9 +266,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function6<R, T1, T2, T3, T4, T5, T6,
|
||||
typedef function6<R, T1, T2, T3, T4, T5, T6,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator>
|
||||
type;
|
||||
@ -270,7 +279,7 @@ namespace boost {
|
||||
struct real_get_function_impl<7>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -289,9 +298,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function7<R, T1, T2, T3, T4, T5, T6, T7,
|
||||
typedef function7<R, T1, T2, T3, T4, T5, T6, T7,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -301,7 +310,7 @@ namespace boost {
|
||||
struct real_get_function_impl<8>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -320,9 +329,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function8<R, T1, T2, T3, T4, T5, T6, T7, T8,
|
||||
typedef function8<R, T1, T2, T3, T4, T5, T6, T7, T8,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -332,7 +341,7 @@ namespace boost {
|
||||
struct real_get_function_impl<9>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -351,9 +360,9 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9,
|
||||
typedef function9<R, T1, T2, T3, T4, T5, T6, T7, T8, T9,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
@ -363,7 +372,7 @@ namespace boost {
|
||||
struct real_get_function_impl<10>
|
||||
{
|
||||
template<
|
||||
typename R,
|
||||
typename R,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
@ -382,151 +391,151 @@ namespace boost {
|
||||
>
|
||||
struct params
|
||||
{
|
||||
typedef function10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
|
||||
typedef function10<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator> type;
|
||||
};
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg1_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg1_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg1_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg2_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg2_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg2_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg3_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg3_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg3_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg4_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg4_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg4_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg5_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg5_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg5_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg6_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg6_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg6_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg7_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg7_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg7_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg8_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg8_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg8_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg9_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg9_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg9_type type;
|
||||
};
|
||||
|
||||
template<bool GetIt, typename Traits>
|
||||
template<bool GetIt, typename Traits>
|
||||
struct get_arg10_type
|
||||
{
|
||||
typedef unusable type;
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
template<typename Traits>
|
||||
struct get_arg10_type<true, Traits>
|
||||
{
|
||||
typedef typename Traits::arg10_type type;
|
||||
};
|
||||
|
||||
template<int X, int Y>
|
||||
template<int X, int Y>
|
||||
struct gte
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = (X >= Y));
|
||||
};
|
||||
|
||||
template<bool IsFunction,
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InT4,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT9,
|
||||
typename InT10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
@ -539,25 +548,25 @@ namespace boost {
|
||||
typedef function_traits<InR> traits;
|
||||
|
||||
typedef typename traits::result_type R;
|
||||
typedef typename get_arg1_type<(gte<(traits::arity), 1>::value),
|
||||
typedef typename get_arg1_type<(gte<(traits::arity), 1>::value),
|
||||
traits>::type T1;
|
||||
typedef typename get_arg2_type<(gte<(traits::arity), 2>::value),
|
||||
typedef typename get_arg2_type<(gte<(traits::arity), 2>::value),
|
||||
traits>::type T2;
|
||||
typedef typename get_arg3_type<(gte<(traits::arity), 3>::value),
|
||||
typedef typename get_arg3_type<(gte<(traits::arity), 3>::value),
|
||||
traits>::type T3;
|
||||
typedef typename get_arg4_type<(gte<(traits::arity), 4>::value),
|
||||
typedef typename get_arg4_type<(gte<(traits::arity), 4>::value),
|
||||
traits>::type T4;
|
||||
typedef typename get_arg5_type<(gte<(traits::arity), 5>::value),
|
||||
typedef typename get_arg5_type<(gte<(traits::arity), 5>::value),
|
||||
traits>::type T5;
|
||||
typedef typename get_arg6_type<(gte<(traits::arity), 6>::value),
|
||||
typedef typename get_arg6_type<(gte<(traits::arity), 6>::value),
|
||||
traits>::type T6;
|
||||
typedef typename get_arg7_type<(gte<(traits::arity), 7>::value),
|
||||
typedef typename get_arg7_type<(gte<(traits::arity), 7>::value),
|
||||
traits>::type T7;
|
||||
typedef typename get_arg8_type<(gte<(traits::arity), 8>::value),
|
||||
typedef typename get_arg8_type<(gte<(traits::arity), 8>::value),
|
||||
traits>::type T8;
|
||||
typedef typename get_arg9_type<(gte<(traits::arity), 9>::value),
|
||||
typedef typename get_arg9_type<(gte<(traits::arity), 9>::value),
|
||||
traits>::type T9;
|
||||
typedef typename get_arg10_type<(gte<(traits::arity), 10>::value),
|
||||
typedef typename get_arg10_type<(gte<(traits::arity), 10>::value),
|
||||
traits>::type T10;
|
||||
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
@ -578,15 +587,15 @@ namespace boost {
|
||||
};
|
||||
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
template<typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
template<typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InT4,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT9,
|
||||
typename InT10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
@ -598,7 +607,7 @@ namespace boost {
|
||||
InT5, InT6, InT7, InT8, InT9, InT10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
InPolicy, InMixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
InAllocator>
|
||||
{
|
||||
// Not a function, so just map the types directly
|
||||
@ -625,20 +634,20 @@ namespace boost {
|
||||
#endif // ndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template<
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InT4,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT9,
|
||||
typename InT10,
|
||||
typename InPolicy = empty_function_policy,
|
||||
typename InMixin = empty_function_mixin,
|
||||
typename InAllocator = std::allocator<function_base>
|
||||
typename InAllocator = std::allocator<function_base>
|
||||
>
|
||||
struct get_function_impl
|
||||
{
|
||||
@ -647,7 +656,7 @@ namespace boost {
|
||||
InR, InT1, InT2, InT3, InT4, InT5,
|
||||
InT6, InT7, InT8, InT9, InT10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
InPolicy, InMixin,
|
||||
InPolicy, InMixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
InAllocator> decoder;
|
||||
typedef typename decoder::R R;
|
||||
@ -685,9 +694,9 @@ namespace boost {
|
||||
|
||||
typedef typename real_get_function_impl<
|
||||
(count_used_args<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value)
|
||||
>::template params<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
|
||||
>::template params<R, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Policy, Mixin,
|
||||
Policy, Mixin,
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
Allocator>::type
|
||||
type;
|
||||
@ -695,25 +704,25 @@ namespace boost {
|
||||
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
template<
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InR,
|
||||
typename InT1,
|
||||
typename InT2,
|
||||
typename InT3,
|
||||
typename InT4,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT5,
|
||||
typename InT6,
|
||||
typename InT7,
|
||||
typename InT8,
|
||||
typename InT9,
|
||||
typename InT10,
|
||||
typename InMyPolicy = empty_function_policy,
|
||||
typename InMyMixin = empty_function_mixin,
|
||||
typename InMyAllocator = std::allocator<function_base>
|
||||
typename InMyAllocator = std::allocator<function_base>
|
||||
>
|
||||
class function_traits_builder
|
||||
{
|
||||
typedef get_function_impl<InR, InT1, InT2, InT3, InT4, InT5, InT6, InT7,
|
||||
InT8, InT9, InT10, InMyPolicy, InMyMixin,
|
||||
typedef get_function_impl<InR, InT1, InT2, InT3, InT4, InT5, InT6, InT7,
|
||||
InT8, InT9, InT10, InMyPolicy, InMyMixin,
|
||||
InMyAllocator>
|
||||
impl;
|
||||
|
||||
@ -740,29 +749,29 @@ namespace boost {
|
||||
|
||||
#ifndef BOOST_NO_DEPENDENT_NESTED_DERIVATIONS
|
||||
template<typename Policy>
|
||||
struct policy :
|
||||
struct policy :
|
||||
public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
|
||||
MyT7, MyT8, MyT9, MyT10, Policy,
|
||||
MyT7, MyT8, MyT9, MyT10, Policy,
|
||||
mixin_type, allocator_type> {};
|
||||
|
||||
template<typename Mixin>
|
||||
struct mixin :
|
||||
struct mixin :
|
||||
public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
|
||||
MyT7, MyT8, MyT9, MyT10, policy_type,
|
||||
MyT7, MyT8, MyT9, MyT10, policy_type,
|
||||
Mixin, allocator_type> {};
|
||||
|
||||
template<typename Allocator>
|
||||
struct allocator :
|
||||
struct allocator :
|
||||
public function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4, MyT5, MyT6,
|
||||
MyT7, MyT8, MyT9, MyT10, policy_type,
|
||||
MyT7, MyT8, MyT9, MyT10, policy_type,
|
||||
mixin_type, Allocator> {};
|
||||
#else
|
||||
template<typename Policy>
|
||||
struct policy
|
||||
struct policy
|
||||
{
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
MyT10, Policy, mixin_type,
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
MyT10, Policy, mixin_type,
|
||||
allocator_type>::type
|
||||
type;
|
||||
};
|
||||
@ -770,8 +779,8 @@ namespace boost {
|
||||
template<typename Mixin>
|
||||
struct mixin
|
||||
{
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
MyT10, policy_type, Mixin,
|
||||
allocator_type>::type
|
||||
type;
|
||||
@ -780,8 +789,8 @@ namespace boost {
|
||||
template<typename Allocator>
|
||||
struct allocator
|
||||
{
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
typedef typename function_traits_builder<MyR, MyT1, MyT2, MyT3, MyT4,
|
||||
MyT5, MyT6, MyT7, MyT8, MyT9,
|
||||
MyT10, policy_type, mixin_type,
|
||||
Allocator>::type
|
||||
type;
|
||||
@ -793,8 +802,8 @@ namespace boost {
|
||||
} // end namespace detail
|
||||
|
||||
template<
|
||||
typename R,
|
||||
typename T1 = detail::function::unusable,
|
||||
typename R,
|
||||
typename T1 = detail::function::unusable,
|
||||
typename T2 = detail::function::unusable,
|
||||
typename T3 = detail::function::unusable,
|
||||
typename T4 = detail::function::unusable,
|
||||
@ -806,16 +815,16 @@ namespace boost {
|
||||
typename T10 = detail::function::unusable
|
||||
>
|
||||
class function :
|
||||
public detail::function::get_function_impl<R, T1, T2, T3, T4, T5, T6, T7,
|
||||
public detail::function::get_function_impl<R, T1, T2, T3, T4, T5, T6, T7,
|
||||
T8, T9, T10>::type
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
, public detail::function::function_traits_builder<R, T1, T2, T3, T4, T5,
|
||||
, public detail::function::function_traits_builder<R, T1, T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10>
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
{
|
||||
typedef typename detail::function::get_function_impl<R, T1, T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10
|
||||
>::type
|
||||
>::type
|
||||
base_type;
|
||||
|
||||
public:
|
||||
@ -823,16 +832,16 @@ namespace boost {
|
||||
typedef typename base_type::policy_type policy_type;
|
||||
typedef typename base_type::mixin_type mixin_type;
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
typedef typename base_type::allocator_type allocator_type;
|
||||
typedef function self_type;
|
||||
|
||||
function() : base_type() {}
|
||||
|
||||
template<typename Functor>
|
||||
typedef typename base_type::allocator_type allocator_type;
|
||||
typedef function self_type;
|
||||
|
||||
function() : base_type() {}
|
||||
|
||||
template<typename Functor>
|
||||
function(Functor BOOST_FUNCTION_TARGET_FIX(const &) f) : base_type(f) {}
|
||||
|
||||
|
||||
function(const self_type& f) : base_type(static_cast<const base_type&>(f)){}
|
||||
|
||||
|
||||
template<typename Functor>
|
||||
self_type& operator=(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
|
||||
{
|
||||
@ -847,38 +856,38 @@ namespace boost {
|
||||
}
|
||||
|
||||
self_type& operator=(const self_type& f)
|
||||
{
|
||||
{
|
||||
self_type(f).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
template<typename Functor>
|
||||
BOOST_FUNCTION_DEPRECATED_PRE
|
||||
void set(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
|
||||
BOOST_FUNCTION_DEPRECATED_PRE
|
||||
void set(Functor BOOST_FUNCTION_TARGET_FIX(const &) f)
|
||||
{
|
||||
BOOST_FUNCTION_DEPRECATED_INNER
|
||||
self_type(f).swap(*this);
|
||||
}
|
||||
|
||||
BOOST_FUNCTION_DEPRECATED_PRE
|
||||
void set(const base_type& f)
|
||||
void set(const base_type& f)
|
||||
{
|
||||
BOOST_FUNCTION_DEPRECATED_INNER
|
||||
self_type(f).swap(*this);
|
||||
}
|
||||
|
||||
BOOST_FUNCTION_DEPRECATED_PRE
|
||||
void set(const self_type& f)
|
||||
void set(const self_type& f)
|
||||
{
|
||||
BOOST_FUNCTION_DEPRECATED_INNER
|
||||
self_type(f).swap(*this);
|
||||
}
|
||||
}
|
||||
#endif // ndef BOOST_FUNCTION_NO_DEPRECATED
|
||||
};
|
||||
|
||||
template<typename R,
|
||||
typename T1,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080">
|
||||
|
||||
<h1><IMG SRC="../../c++boost.gif" WIDTH="276" HEIGHT="86">Header <<a HREF="../../boost/function.hpp">boost/function.hpp</a>></h1>
|
||||
<h1><IMG SRC="../../c++boost.gif" WIDTH="276" HEIGHT="86" alt="C++ Boost">Header <<a HREF="../../boost/function.hpp">boost/function.hpp</a>></h1>
|
||||
|
||||
<p> The header <<a HREF="../../boost/function.hpp">boost/function.hpp</a>> includes a family of class templates that are function object wrappers. The notion is similar to a generalized callback. It shares features with function pointers in that both define a call interface (e.g., a function taking two integer arguments and returning a floating-point value) through which some implementation can be called, and the implementation that is invoked may change throughout the course of the program.
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<li><a href="doc/faq.html">Frequently Asked Questions</a></li>
|
||||
</ul>
|
||||
|
||||
<a name="compatibility"><h2>Compatibility Note</h2></a>
|
||||
<h2><a name="compatibility">Compatibility Note</a></h2>
|
||||
<p> Boost.Function has been partially redesigned to minimize the interface and make it cleaner. Several seldom- or never-used features of the older Boost.Function have been deprecated and will be removed in the near future. Here is a list of features that have been deprecated, the likely impact of the deprecations, and how to adjust your code:
|
||||
<ul>
|
||||
<li>The <code>boost::function</code> class template syntax has
|
||||
@ -127,6 +127,6 @@ And, of course, function pointers have several advantages over Boost.Function:
|
||||
<p> Many people were involved in the construction of this library. William Kempf, Jesse Jones and Karl Nelson were all extremely helpful in isolating an interface and scope for the library. John Maddock managed the formal review, and many reviewers gave excellent comments on interface, implementation, and documentation.
|
||||
|
||||
<hr>
|
||||
<address><a href="mailto:gregod@cs.rpi.edu">Doug Gregor</a></address>
|
||||
<address><a href="http://www.cs.rpi.edu/~gregod">Doug Gregor</a></address>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user