mirror of
https://github.com/boostorg/lambda.git
synced 2026-01-21 17:02:36 +00:00
Compare commits
15 Commits
boost-1.30
...
svn-tags/m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94263339cd | ||
|
|
b8d328c0fc | ||
|
|
c5704cd6e3 | ||
|
|
6f607b3eef | ||
|
|
8bb8820adb | ||
|
|
89fb84d751 | ||
|
|
be2b0df062 | ||
|
|
666a3eca2d | ||
|
|
95d865285e | ||
|
|
ec38046886 | ||
|
|
c713dc5e0c | ||
|
|
ff04032656 | ||
|
|
6f63b3770f | ||
|
|
22e7b9c779 | ||
|
|
68be6f6563 |
@@ -5,7 +5,7 @@
|
||||
The Boost Lambda Library"><link rel="up" href="index.html" title="
|
||||
C++ BOOST
|
||||
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s09.html" title="9. Contributors"><link rel="next" href="bi01.html" title="Bibliography"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">A. Rationale for some of the design decisions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s09.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="bi01.html">Next</a></td></tr></table><hr></div><div class="appendix"><h2 class="title" style="clear: both"><a name="id2808823"></a>A. Rationale for some of the design decisions</h2><div class="section"><div class="titlepage"><div><h3 class="title"><a name="sect:why_weak_arity"></a>1.
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s09.html" title="9. Contributors"><link rel="next" href="bi01.html" title="Bibliography"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">A. Rationale for some of the design decisions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s09.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="bi01.html">Next</a></td></tr></table><hr></div><div class="appendix"><h2 class="title" style="clear: both"><a name="id2808845"></a>A. Rationale for some of the design decisions</h2><div class="section"><div class="titlepage"><div><h3 class="title"><a name="sect:why_weak_arity"></a>1.
|
||||
Lambda functor arity
|
||||
</h3></div></div><p>
|
||||
The highest placeholder index in a lambda expression determines the arity of the resulting function object.
|
||||
|
||||
@@ -122,19 +122,18 @@ in the lambda functor.
|
||||
This means that the value of a bound argument is fixed at the time of the
|
||||
creation of the lambda function and remains constant during the lifetime
|
||||
of the lambda function object.
|
||||
|
||||
For example:
|
||||
|
||||
<pre class="programlisting">
|
||||
int i = 1;
|
||||
(_1 + i)(i = 2);
|
||||
(_1 = 2, _1 + i)(i);
|
||||
</pre>
|
||||
|
||||
The comma operator is overloaded to combine lambda expressions into a sequence;
|
||||
the resulting unary lambda functor first assigns 2 to its argument,
|
||||
then adds the value of <tt>i</tt> to it.
|
||||
The value of the expression in the last line is 3, not 4.
|
||||
|
||||
In other words, the lambda expression <tt>_1 + i</tt> creates
|
||||
a lambda function <tt>lambda x.x+1</tt> rather than
|
||||
<tt>lambda x.x+i</tt>.
|
||||
In other words, the lambda expression that is created is
|
||||
<tt>lambda x.(x = 2, x + 1)</tt> rather than
|
||||
<tt>lambda x.(x = 2, x + i)</tt>.
|
||||
|
||||
</p><p>
|
||||
|
||||
@@ -152,12 +151,12 @@ or as a reference to const respectively.
|
||||
|
||||
For example, if we rewrite the previous example and wrap the variable
|
||||
<tt>i</tt> with <tt>ref</tt>,
|
||||
we are creating the lambda expression <tt>lambda x.x+i</tt>
|
||||
we are creating the lambda expression <tt>lambda x.(x = 2, x + i)</tt>
|
||||
and the value of the expression in the last line will be 4:
|
||||
|
||||
<pre class="programlisting">
|
||||
i = 1;
|
||||
(_1 + ref(i))(i = 2);
|
||||
(_1 = 2, _1 + ref(i))(i);
|
||||
</pre>
|
||||
|
||||
Note that <tt>ref</tt> and <tt>cref</tt> are different
|
||||
|
||||
@@ -77,7 +77,7 @@ For example, the following is a valid lambda expression:
|
||||
<pre class="programlisting">cout << _1, _2[_3] = _1 && false</pre>
|
||||
</p><p>
|
||||
However, there are some restrictions that originate from the C++ operator overloading rules, and some special cases.
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2740645"></a>5.2.1. Operators that cannot be overloaded</h4></div></div><p>
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2740648"></a>5.2.1. Operators that cannot be overloaded</h4></div></div><p>
|
||||
Some operators cannot be overloaded at all (<tt>::</tt>, <tt>.</tt>, <tt>.*</tt>).
|
||||
For some operators, the requirements on return types prevent them to be overloaded to create lambda functors.
|
||||
These operators are <tt>->.</tt>, <tt>-></tt>, <tt>new</tt>, <tt>new[]</tt>, <tt>delete</tt>, <tt>delete[]</tt> and <tt>?:</tt> (the conditional operator).
|
||||
@@ -308,12 +308,32 @@ operator defined, can be used as target functions.
|
||||
|
||||
In general, BLL cannot deduce the return type of an arbitrary function object.
|
||||
|
||||
However, there is a method for giving BLL this capability for a certain
|
||||
However, there are two methods for giving BLL this capability for a certain
|
||||
function object class.
|
||||
|
||||
</p><div class="simplesect"><div class="titlepage"><div><h5 class="title"><a name="id2803246"></a>The sig template</h5></div></div><p>
|
||||
To make BLL aware of the return type(s) of a function object one needs to
|
||||
provide a member template struct
|
||||
</p><div class="simplesect"><div class="titlepage"><div><h5 class="title"><a name="id2803250"></a>The result_type typedef</h5></div></div><p>
|
||||
|
||||
The BLL supports the standard library convention of declaring the return type
|
||||
of a function object with a member typedef named <tt>result_type</tt> in the
|
||||
function object class.
|
||||
|
||||
Here is a simple example:
|
||||
<pre class="programlisting">
|
||||
struct A {
|
||||
typedef B result_type;
|
||||
B operator()(X, Y, Z);
|
||||
};
|
||||
</pre>
|
||||
|
||||
If a function object does not define a <tt>result_type</tt> typedef,
|
||||
the method described below (<tt>sig</tt> template)
|
||||
is attempted to resolve the return type of the
|
||||
function object. If a function object defines both <tt>result_type</tt>
|
||||
and <tt>sig</tt>, <tt>result_type</tt> takes precedence.
|
||||
|
||||
</p></div><div class="simplesect"><div class="titlepage"><div><h5 class="title"><a name="id2803321"></a>The sig template</h5></div></div><p>
|
||||
Another mechanism that make BLL aware of the return type(s) of a function object is defining
|
||||
member template struct
|
||||
<tt>sig<Args></tt> with a typedef
|
||||
<tt>type</tt> that specifies the return type.
|
||||
|
||||
@@ -332,9 +352,7 @@ is the function
|
||||
object type itself, and the remaining elements are the types of
|
||||
the arguments, with which the function object is being called.
|
||||
|
||||
This may seem overly complex compared to the Standard Library
|
||||
convention for defining the return type of a function
|
||||
object with the <tt>return_type</tt> typedef.
|
||||
This may seem overly complex compared to defining the <tt>result_type</tt> typedef.
|
||||
Howver, there are two significant restrictions with using just a simple
|
||||
typedef to express the return type:
|
||||
<div class="orderedlist"><ol type="1"><li><p>
|
||||
@@ -396,25 +414,7 @@ for tools that can aid in these tasks.
|
||||
The <tt>sig</tt> templates are a refined version of a similar
|
||||
mechanism first introduced in the FC++ library
|
||||
[<a href="bi01.html#cit:fc++" title="[fc++]">fc++</a>].
|
||||
</p></div><p>
|
||||
Earlier versions of the library supported the Standard Library convention
|
||||
as the default, and required special actions to make the library recognize
|
||||
the <tt>sig</tt> template.
|
||||
Now the BLL has that reversed.
|
||||
|
||||
If one needs to use a functor that adheres to the Standard Library
|
||||
convention in a bind expression, we provide the <tt>std_functor</tt>
|
||||
wrapper, that gives the function object a <tt>sig</tt>
|
||||
template based on the <tt>result_type</tt> typedef.
|
||||
For example:
|
||||
|
||||
<pre class="programlisting">
|
||||
int i = 1;
|
||||
bind(plus<int>(), _1, 1)(i); // error, no sig template
|
||||
bind(std_functor(plus<int>()), _1, 1)(i); // ok
|
||||
</pre>
|
||||
|
||||
</p></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="sect:overriding_deduced_return_type"></a>5.4. Overriding the deduced return type</h3></div></div><p>
|
||||
</p></div></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="sect:overriding_deduced_return_type"></a>5.4. Overriding the deduced return type</h3></div></div><p>
|
||||
The return type deduction system may not be able to deduce the return types of some user defined operators or bind expressions with class objects.
|
||||
|
||||
A special lambda expression type is provided for stating the return type explicitly and overriding the deduction system.
|
||||
@@ -533,7 +533,7 @@ By using <tt>var</tt> to make <tt>index</tt> a lambda expression, we get the des
|
||||
In sum, <tt>var(x)</tt> creates a nullary lambda functor,
|
||||
which stores a reference to the variable <tt>x</tt>.
|
||||
When the lambda functor is invoked, a reference to <tt>x</tt> is returned.
|
||||
</p><div class="simplesect"><div class="titlepage"><div><h4 class="title"><a name="id2804092"></a>Naming delayed constants and variables</h4></div></div><p>
|
||||
</p><div class="simplesect"><div class="titlepage"><div><h4 class="title"><a name="id2804115"></a>Naming delayed constants and variables</h4></div></div><p>
|
||||
It is possible to predefine and name a delayed variable or constant outside a lambda expression.
|
||||
The templates <tt>var_type</tt>, <tt>constant_type</tt>
|
||||
and <tt>constant_ref_type</tt> serve for this purpose.
|
||||
@@ -562,7 +562,7 @@ Here is an example of naming a delayed constant:
|
||||
constant_type<char>::type space(constant(' '));
|
||||
for_each(a.begin(),a.end(), cout << space << _1);
|
||||
</pre>
|
||||
</p></div><div class="simplesect"><div class="titlepage"><div><h4 class="title"><a name="id2804216"></a>About assignment and subscript operators</h4></div></div><p>
|
||||
</p></div><div class="simplesect"><div class="titlepage"><div><h4 class="title"><a name="id2804238"></a>About assignment and subscript operators</h4></div></div><p>
|
||||
As described in <a href="ar01s05.html#sect:assignment_and_subscript" title="5.2.2. Assignment and subscript operators">Section 5.2.2</a>, assignment and subscripting operators are always defined as member functions.
|
||||
This means, that for expressions of the form
|
||||
<tt>x = y</tt> or <tt>x[y]</tt> to be interpreted as lambda expressions, the left-hand operand <tt>x</tt> must be a lambda expression.
|
||||
@@ -649,7 +649,7 @@ For example, using this syntax the <tt>if_then</tt> example above
|
||||
can be written as:
|
||||
<pre class="programlisting">
|
||||
for_each(a.begin(), a.end(),
|
||||
if(_1 % 2 == 0)[ cout << _1 ])
|
||||
if_(_1 % 2 == 0)[ cout << _1 ])
|
||||
</pre>
|
||||
|
||||
As more experience is gained, we may end up deprecating one or the other
|
||||
@@ -850,7 +850,7 @@ objects related to creating and destroying objects,
|
||||
showing the expression to create and call the function object,
|
||||
and the effect of evaluating that expression.
|
||||
|
||||
</p><div class="table"><p><a name="table:constructor_destructor_fos"></a><b>Table 1. Construction and destruction related function objects.</b></p><table summary="Construction and destruction related function objects." border="1"><colgroup><col><col></colgroup><thead><tr><th>Function object call</th><th>Wrapped expression</th></tr></thead><tbody><tr><td><tt>constructor<T>()(<i><tt>arg_list</tt></i>)</tt></td><td>T(<i><tt>arg_list</tt></i>)</td></tr><tr><td><tt>destructor()(a)</tt></td><td><tt>a.~A()</tt>, where <tt>a</tt> is of type <tt>A</tt></td></tr><tr><td><tt>destructor()(pa)</tt></td><td><tt>pa.->A()</tt>, where <tt>pa</tt> is of type <tt>A*</tt></td></tr><tr><td><tt>new_ptr<T>()(<i><tt>arg_list</tt></i>)</tt></td><td><tt>new T(<i><tt>arg_list</tt></i>)</tt></td></tr><tr><td><tt>new_array<T>()(sz)</tt></td><td><tt>new T[sz]</tt></td></tr><tr><td><tt>delete_ptr()(p)</tt></td><td><tt>delete p</tt></td></tr><tr><td><tt>delete_array()(p)</tt></td><td><tt>delete p[]</tt></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2805484"></a>5.9. Special lambda expressions</h3></div></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2805492"></a>5.9.1. Preventing argument substitution</h4></div></div><p>
|
||||
</p><div class="table"><p><a name="table:constructor_destructor_fos"></a><b>Table 1. Construction and destruction related function objects.</b></p><table summary="Construction and destruction related function objects." border="1"><colgroup><col><col></colgroup><thead><tr><th>Function object call</th><th>Wrapped expression</th></tr></thead><tbody><tr><td><tt>constructor<T>()(<i><tt>arg_list</tt></i>)</tt></td><td>T(<i><tt>arg_list</tt></i>)</td></tr><tr><td><tt>destructor()(a)</tt></td><td><tt>a.~A()</tt>, where <tt>a</tt> is of type <tt>A</tt></td></tr><tr><td><tt>destructor()(pa)</tt></td><td><tt>pa->~A()</tt>, where <tt>pa</tt> is of type <tt>A*</tt></td></tr><tr><td><tt>new_ptr<T>()(<i><tt>arg_list</tt></i>)</tt></td><td><tt>new T(<i><tt>arg_list</tt></i>)</tt></td></tr><tr><td><tt>new_array<T>()(sz)</tt></td><td><tt>new T[sz]</tt></td></tr><tr><td><tt>delete_ptr()(p)</tt></td><td><tt>delete p</tt></td></tr><tr><td><tt>delete_array()(p)</tt></td><td><tt>delete p[]</tt></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2805507"></a>5.9. Special lambda expressions</h3></div></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2805514"></a>5.9.1. Preventing argument substitution</h4></div></div><p>
|
||||
When a lambda functor is called, the default behavior is to substitute
|
||||
the actual arguments for the placeholders within all subexpressions.
|
||||
|
||||
@@ -976,7 +976,7 @@ int nested(const F& f) {
|
||||
}
|
||||
</pre>
|
||||
|
||||
</p></div><div class="section"><div class="titlepage"><div><h5 class="title"><a name="id2805751"></a>5.9.1.2. Protect</h5></div></div><p>
|
||||
</p></div><div class="section"><div class="titlepage"><div><h5 class="title"><a name="id2805774"></a>5.9.1.2. Protect</h5></div></div><p>
|
||||
The <tt>protect</tt> function is related to unlambda.
|
||||
|
||||
It is also used to prevent the argument substitution taking place,
|
||||
@@ -1081,7 +1081,7 @@ since calls to sub lambda functors are made inside the BLL,
|
||||
and are not affected by the non-const rvalue problem.
|
||||
</p></li></ol></div>
|
||||
|
||||
</p></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2806057"></a>5.10. Casts, sizeof and typeid</h3></div></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="sect:cast_expressions"></a>5.10.1.
|
||||
</p></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2806080"></a>5.10. Casts, sizeof and typeid</h3></div></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="sect:cast_expressions"></a>5.10.1.
|
||||
Cast expressions
|
||||
</h4></div></div><p>
|
||||
The BLL defines its counterparts for the four cast expressions
|
||||
@@ -1110,7 +1110,7 @@ int count = 0;
|
||||
for_each(a.begin(), a.end(),
|
||||
if_then(ll_dynamic_cast<derived*>(_1), ++var(count)));
|
||||
</pre>
|
||||
</p></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2806159"></a>5.10.2. Sizeof and typeid</h4></div></div><p>
|
||||
</p></div><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2806181"></a>5.10.2. Sizeof and typeid</h4></div></div><p>
|
||||
The BLL counterparts for these expressions are named
|
||||
<tt>ll_sizeof</tt> and <tt>ll_typeid</tt>.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
The Boost Lambda Library"><link rel="up" href="index.html" title="
|
||||
C++ BOOST
|
||||
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s06.html" title="6. Extending return type deduction system"><link rel="next" href="ar01s08.html" title="8. Relation to other Boost libraries"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">7. Practical considerations</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s06.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s08.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2807566"></a>7. Practical considerations</h2></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2807572"></a>7.1. Performance</h3></div></div><p>In theory, all overhead of using STL algorithms and lambda functors
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s06.html" title="6. Extending return type deduction system"><link rel="next" href="ar01s08.html" title="8. Relation to other Boost libraries"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">7. Practical considerations</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s06.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s08.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2807588"></a>7. Practical considerations</h2></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2807595"></a>7.1. Performance</h3></div></div><p>In theory, all overhead of using STL algorithms and lambda functors
|
||||
compared to hand written loops can be optimized away, just as the overhead
|
||||
from standard STL function objects and binders can.
|
||||
|
||||
@@ -97,7 +97,7 @@ The running times are expressed in arbitrary units." border="1"><colgroup><col><
|
||||
</p><p>Some additional performance testing with an earlier version of the
|
||||
library is described
|
||||
[<a href="bi01.html#cit:jarvi:00" title="[Jär00]">Jär00</a>].
|
||||
</p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808065"></a>7.2. About compiling</h3></div></div><p>The BLL uses templates rather heavily, performing numerous recursive instantiations of the same templates.
|
||||
</p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808087"></a>7.2. About compiling</h3></div></div><p>The BLL uses templates rather heavily, performing numerous recursive instantiations of the same templates.
|
||||
This has (at least) three implications:
|
||||
<div class="itemizedlist"><ul type="disc"><li><p>
|
||||
While it is possible to write incredibly complex lambda expressions, it probably isn't a good idea.
|
||||
@@ -111,7 +111,7 @@ This can make the error messages very long and difficult to interpret, particula
|
||||
The C++ Standard suggests a template nesting level of 17 to help detect infinite recursion.
|
||||
Complex lambda templates can easily exceed this limit.
|
||||
Most compilers allow a greater number of nested templates, but commonly require the limit explicitly increased with a command line argument.
|
||||
</p></li></ul></div></p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808126"></a>7.3. Portability</h3></div></div><p>
|
||||
</p></li></ul></div></p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808149"></a>7.3. Portability</h3></div></div><p>
|
||||
The BLL works with the following compilers, that is, the compilers are capable of compiling the test cases that are included with the BLL:
|
||||
|
||||
<div class="itemizedlist"><ul type="disc"><li>GCC 3.0.4
|
||||
@@ -120,7 +120,7 @@ The BLL works with the following compilers, that is, the compilers are capable o
|
||||
)
|
||||
|
||||
</li></ul></div>
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2808166"></a>7.3.1. Test coverage</h4></div></div><p>The following list describes the test files included and the features that each file covers:
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2808188"></a>7.3.1. Test coverage</h4></div></div><p>The following list describes the test files included and the features that each file covers:
|
||||
|
||||
<div class="itemizedlist"><ul type="disc"><li><p>
|
||||
<tt>bind_tests_simple.cpp</tt> : Bind expressions of different arities and types of target functions: function pointers, function objects and member functions.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
The Boost Lambda Library"><link rel="up" href="index.html" title="
|
||||
C++ BOOST
|
||||
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s07.html" title="7. Practical considerations"><link rel="next" href="ar01s09.html" title="9. Contributors"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">8. Relation to other Boost libraries</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s07.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s09.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2808510"></a>8. Relation to other Boost libraries</h2></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808518"></a>8.1. Boost Function</h3></div></div><p>Sometimes it is convenient to store lambda functors in variables.
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s07.html" title="7. Practical considerations"><link rel="next" href="ar01s09.html" title="9. Contributors"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">8. Relation to other Boost libraries</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s07.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s09.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2808533"></a>8. Relation to other Boost libraries</h2></div></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808540"></a>8.1. Boost Function</h3></div></div><p>Sometimes it is convenient to store lambda functors in variables.
|
||||
However, the types of even the simplest lambda functors are long and unwieldy, and it is in general unfeasible to declare variables with lambda functor types.
|
||||
<span class="emphasis"><i>The Boost Function library</i></span> [<a href="bi01.html#cit:boost::function" title="[function]">function</a>] defines wrappers for arbitrary function objects, for example
|
||||
lambda functors; and these wrappers have types that are easy to type out.
|
||||
@@ -16,8 +16,8 @@ For example:
|
||||
boost::function<int(int, int)> f = _1 + _2;
|
||||
boost::function<int&(int&)> g = (_1 += 10);
|
||||
int i = 1, j = 2;
|
||||
f(i); // returns 3
|
||||
g(i); // sets i to = 11;
|
||||
f(i, j); // returns 3
|
||||
g(i); // sets i to = 11;
|
||||
</pre>
|
||||
|
||||
The return and parameter types of the wrapped function object must be written explicilty as the template argument to the wrapper template <tt>boost::function</tt>; even when lambda functors, which otherwise have generic parameters, are wrapped.
|
||||
@@ -44,7 +44,7 @@ delete sum;
|
||||
counter(3); // error, *sum does not exist anymore
|
||||
</pre>
|
||||
|
||||
</p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808622"></a>8.2. Boost Bind</h3></div></div><p>
|
||||
</p></div><div class="section"><div class="titlepage"><div><h3 class="title"><a name="id2808644"></a>8.2. Boost Bind</h3></div></div><p>
|
||||
<span class="emphasis"><i>The Boost Bind</i></span> [<a href="bi01.html#cit:boost::bind" title="[bind]">bind</a>] library has partially overlapping functionality with the BLL.
|
||||
Basically, the Boost Bind library (BB in the sequel) implements the bind expression part of BLL.
|
||||
There are, however, some semantical differerences.
|
||||
@@ -63,7 +63,7 @@ a larger set of compilers.
|
||||
</p><p>
|
||||
The following two sections describe what are the semantic differences
|
||||
between the bind expressions in BB and BLL.
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2808686"></a>8.2.1. First argument of bind expression</h4></div></div>
|
||||
</p><div class="section"><div class="titlepage"><div><h4 class="title"><a name="id2808709"></a>8.2.1. First argument of bind expression</h4></div></div>
|
||||
|
||||
In BB the first argument of the bind expression, the target function,
|
||||
is treated differently from the other arguments,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
The Boost Lambda Library"><link rel="up" href="index.html" title="
|
||||
C++ BOOST
|
||||
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s08.html" title="8. Relation to other Boost libraries"><link rel="next" href="apa.html" title="A. Rationale for some of the design decisions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">9. Contributors</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s08.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2808801"></a>9. Contributors</h2></div></div>
|
||||
The Boost Lambda Library"><link rel="previous" href="ar01s08.html" title="8. Relation to other Boost libraries"><link rel="next" href="apa.html" title="A. Rationale for some of the design decisions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">9. Contributors</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s08.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2808824"></a>9. Contributors</h2></div></div>
|
||||
|
||||
The main body of the library was written by Jaakko Järvi and Gary Powell.
|
||||
We've got outside help, suggestions and ideas from Jeremy Siek, Peter Higley, Peter Dimov, Valentin Bonnard, William Kempf.
|
||||
|
||||
@@ -5,12 +5,21 @@
|
||||
The Boost Lambda Library"><link rel="up" href="index.html" title="
|
||||
C++ BOOST
|
||||
|
||||
The Boost Lambda Library"><link rel="previous" href="apa.html" title="A. Rationale for some of the design decisions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Bibliography</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apa.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div id="id2808975" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="id2808975"></a>Bibliography</h2></div></div><div class="biblioentry"><a name="cit:stepanov:94"></a><p>[STL94] <span class="authorgroup">A. A. Stepanov and M. Lee. </span><span class="title"><I>The Standard Template Library</I>. </span><span class="orgname">Hewlett-Packard Laboratories. </span><span class="pubdate">1994. </span><span class="bibliomisc">
|
||||
The Boost Lambda Library"><link rel="previous" href="apa.html" title="A. Rationale for some of the design decisions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Bibliography</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="apa.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div id="id2808997" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="id2808997"></a>Bibliography</h2></div></div><div class="biblioentry"><a name="cit:stepanov:94"></a><p>[STL94] <span class="authorgroup">A. A. Stepanov and M. Lee. </span><span class="title"><I>The Standard Template Library</I>. </span><span class="orgname">Hewlett-Packard Laboratories. </span><span class="pubdate">1994. </span><span class="bibliomisc">
|
||||
<a href="http://www.hpl.hp.com/techreports" target="_top">www.hpl.hp.com/techreports</a>
|
||||
. </span></p></div><div class="biblioentry"><a name="cit:sgi:02"></a><p>[SGI02] <span class="title"><I>The SGI Standard Template Library</I>. </span><span class="pubdate">2002. </span><span class="bibliomisc"><a href="http://www.sgi.com/tech/stl/" target="_top">www.sgi.com/tech/stl/</a>. </span></p></div><div class="biblioentry"><a name="cit:c++:98"></a><p>[C++98] <span class="title"><I>International Standard, Programming Languages – C++</I>. </span><span class="subtitle">ISO/IEC:14882. </span><span class="pubdate">1998. </span></p></div><div class="biblioentry"><a name="cit:jarvi:99"></a><p>[Jär99] <span class="articleinfo">
|
||||
<span class="author">Jaakko Järvi. </span>
|
||||
<span class="title"><I>C++ Function Object Binders Made Easy</I>. </span>
|
||||
. </span><span class="title"><I>Lecture Notes in Computer Science</I>. </span><span class="volumenum">1977. </span><span class="publishername">Springer. </span><span class="pubdate">2000. </span></p></div><div class="biblioentry"><a name="cit:jarvi:00"></a><p>[Jär00] <span class="author">Jaakko Järvi. </span><span class="author">Gary Powell. </span><span class="title"><I>The Lambda Library : Lambda Abstraction in C++</I>. </span><span class="orgname">Turku Centre for Computer Science. </span><span class="bibliomisc">Technical Report . </span><span class="issuenum">378. </span><span class="pubdate">2000. </span><span class="bibliomisc"><a href="http://www.tucs.fi/Publications/techreports/TR378.php" target="_top">www.tucs.fi/publications</a>. </span></p></div><div class="biblioentry"><a name="cit:jarvi:01"></a><p>[Jär01] <span class="author">Jaakko Järvi. </span><span class="author">Gary Powell. </span><span class="title"><I>The Lambda Library : Lambda Abstraction in C++</I>. </span><span class="confgroup"><span class="conftitle">Second Workshop on C++ Template Programming. </span><span class="address">Tampa Bay, OOPSLA'01. </span>. </span><span class="pubdate">2001. </span><span class="bibliomisc"><a href="http://www.oonumerics.org/tmpw01/" target="_top">www.oonumerics.org/tmpw01/</a>. </span></p></div><div class="biblioentry"><a name="cit:boost::tuple"></a><p>[tuple] <span class="title"><I>The Boost Tuple Library</I>. </span><span class="bibliomisc"><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html" target="_top">www.boost.org/libs/tuple/doc/tuple_users_guide.html</a>
|
||||
. </span><span class="title"><I>Lecture Notes in Computer Science</I>. </span><span class="volumenum">1977. </span><span class="publishername">Springer. </span><span class="pubdate">2000. </span></p></div><div class="biblioentry"><a name="cit:jarvi:00"></a><p>[Jär00] <span class="author">Jaakko Järvi. </span><span class="author">Gary Powell. </span><span class="title"><I>The Lambda Library : Lambda Abstraction in C++</I>. </span><span class="orgname">Turku Centre for Computer Science. </span><span class="bibliomisc">Technical Report . </span><span class="issuenum">378. </span><span class="pubdate">2000. </span><span class="bibliomisc"><a href="http://www.tucs.fi/Publications/techreports/TR378.php" target="_top">www.tucs.fi/publications</a>. </span></p></div><div class="biblioentry"><a name="cit:jarvi:01"></a><p>[Jär01] <span class="author">Jaakko Järvi. </span><span class="author">Gary Powell. </span><span class="title"><I>The Lambda Library : Lambda Abstraction in C++</I>. </span><span class="confgroup"><span class="conftitle">Second Workshop on C++ Template Programming. </span><span class="address">Tampa Bay, OOPSLA'01. </span>. </span><span class="pubdate">2001. </span><span class="bibliomisc"><a href="http://www.oonumerics.org/tmpw01/" target="_top">www.oonumerics.org/tmpw01/</a>. </span></p></div><div class="biblioentry"><a name="cit:jarvi:03"></a><p>[Jär03] <span class="articleinfo">
|
||||
|
||||
<span class="author">Jaakko Järvi. </span>
|
||||
|
||||
<span class="author">Gary Powell. </span>
|
||||
|
||||
<span class="author">Andrew Lumsdaine. </span>
|
||||
<span class="title"><I>The Lambda Library : unnamed functions in C++</I>. </span>
|
||||
|
||||
. </span><span class="title"><I>Software - Practice and Expreience</I>. </span><span class="volumenum">33:259-291. </span><span class="pubdate">2003. </span></p></div><div class="biblioentry"><a name="cit:boost::tuple"></a><p>[tuple] <span class="title"><I>The Boost Tuple Library</I>. </span><span class="bibliomisc"><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html" target="_top">www.boost.org/libs/tuple/doc/tuple_users_guide.html</a>
|
||||
. </span><span class="pubdate">2002. </span></p></div><div class="biblioentry"><a name="cit:boost::type_traits"></a><p>[type_traits] <span class="title"><I>The Boost type_traits</I>. </span><span class="bibliomisc"><a href="http://www.boost.org/libs/type_traits/index.htm" target="_top">www.boost.org/libs/type_traits/</a>
|
||||
. </span><span class="pubdate">2002. </span></p></div><div class="biblioentry"><a name="cit:boost::ref"></a><p>[ref] <span class="title"><I>Boost ref</I>. </span><span class="bibliomisc"><a href="http://www.boost.org/libs/bind/ref.html" target="_top">www.boost.org/libs/bind/ref.html</a>
|
||||
. </span><span class="pubdate">2002. </span></p></div><div class="biblioentry"><a name="cit:boost::bind"></a><p>[bind] <span class="title"><I>Boost Bind Library</I>. </span><span class="bibliomisc"><a href="http://www.boost.org/libs/bind/bind.html" target="_top">www.boost.org/libs/bind/bind.html</a>
|
||||
|
||||
@@ -588,19 +588,18 @@ in the lambda functor.
|
||||
This means that the value of a bound argument is fixed at the time of the
|
||||
creation of the lambda function and remains constant during the lifetime
|
||||
of the lambda function object.
|
||||
|
||||
For example:
|
||||
|
||||
<programlisting>
|
||||
int i = 1;
|
||||
(_1 + i)(i = 2);
|
||||
(_1 = 2, _1 + i)(i);
|
||||
</programlisting>
|
||||
|
||||
The comma operator is overloaded to combine lambda expressions into a sequence;
|
||||
the resulting unary lambda functor first assigns 2 to its argument,
|
||||
then adds the value of <literal>i</literal> to it.
|
||||
The value of the expression in the last line is 3, not 4.
|
||||
|
||||
In other words, the lambda expression <literal>_1 + i</literal> creates
|
||||
a lambda function <literal>lambda x.x+1</literal> rather than
|
||||
<literal>lambda x.x+i</literal>.
|
||||
In other words, the lambda expression that is created is
|
||||
<literal>lambda x.(x = 2, x + 1)</literal> rather than
|
||||
<literal>lambda x.(x = 2, x + i)</literal>.
|
||||
|
||||
</para>
|
||||
|
||||
@@ -624,12 +623,12 @@ or as a reference to const respectively.
|
||||
|
||||
For example, if we rewrite the previous example and wrap the variable
|
||||
<literal>i</literal> with <literal>ref</literal>,
|
||||
we are creating the lambda expression <literal>lambda x.x+i</literal>
|
||||
we are creating the lambda expression <literal>lambda x.(x = 2, x + i)</literal>
|
||||
and the value of the expression in the last line will be 4:
|
||||
|
||||
<programlisting>
|
||||
i = 1;
|
||||
(_1 + ref(i))(i = 2);
|
||||
(_1 = 2, _1 + ref(i))(i);
|
||||
</programlisting>
|
||||
|
||||
Note that <literal>ref</literal> and <literal>cref</literal> are different
|
||||
@@ -1157,18 +1156,46 @@ operator defined, can be used as target functions.
|
||||
|
||||
In general, BLL cannot deduce the return type of an arbitrary function object.
|
||||
|
||||
However, there is a method for giving BLL this capability for a certain
|
||||
However, there are two methods for giving BLL this capability for a certain
|
||||
function object class.
|
||||
|
||||
</para>
|
||||
|
||||
<simplesect>
|
||||
|
||||
<title>The result_type typedef</title>
|
||||
|
||||
<para>
|
||||
|
||||
The BLL supports the standard library convention of declaring the return type
|
||||
of a function object with a member typedef named <literal>result_type</literal> in the
|
||||
function object class.
|
||||
|
||||
Here is a simple example:
|
||||
<programlisting>
|
||||
<![CDATA[struct A {
|
||||
typedef B result_type;
|
||||
B operator()(X, Y, Z);
|
||||
};]]>
|
||||
</programlisting>
|
||||
|
||||
If a function object does not define a <literal>result_type</literal> typedef,
|
||||
the method described below (<literal>sig</literal> template)
|
||||
is attempted to resolve the return type of the
|
||||
function object. If a function object defines both <literal>result_type</literal>
|
||||
and <literal>sig</literal>, <literal>result_type</literal> takes precedence.
|
||||
|
||||
</para>
|
||||
|
||||
</simplesect>
|
||||
|
||||
<simplesect>
|
||||
|
||||
<title>The sig template</title>
|
||||
|
||||
<para>
|
||||
To make BLL aware of the return type(s) of a function object one needs to
|
||||
provide a member template struct
|
||||
Another mechanism that make BLL aware of the return type(s) of a function object is defining
|
||||
member template struct
|
||||
<literal><![CDATA[sig<Args>]]></literal> with a typedef
|
||||
<literal>type</literal> that specifies the return type.
|
||||
|
||||
@@ -1187,9 +1214,7 @@ is the function
|
||||
object type itself, and the remaining elements are the types of
|
||||
the arguments, with which the function object is being called.
|
||||
|
||||
This may seem overly complex compared to the Standard Library
|
||||
convention for defining the return type of a function
|
||||
object with the <literal>return_type</literal> typedef.
|
||||
This may seem overly complex compared to defining the <literal>result_type</literal> typedef.
|
||||
Howver, there are two significant restrictions with using just a simple
|
||||
typedef to express the return type:
|
||||
<orderedlist>
|
||||
@@ -1264,27 +1289,6 @@ mechanism first introduced in the FC++ library
|
||||
|
||||
</simplesect>
|
||||
|
||||
<para>
|
||||
Earlier versions of the library supported the Standard Library convention
|
||||
as the default, and required special actions to make the library recognize
|
||||
the <literal>sig</literal> template.
|
||||
Now the BLL has that reversed.
|
||||
|
||||
If one needs to use a functor that adheres to the Standard Library
|
||||
convention in a bind expression, we provide the <literal>std_functor</literal>
|
||||
wrapper, that gives the function object a <literal>sig</literal>
|
||||
template based on the <literal>result_type</literal> typedef.
|
||||
For example:
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[int i = 1;
|
||||
bind(plus<int>(), _1, 1)(i); // error, no sig template
|
||||
bind(std_functor(plus<int>()), _1, 1)(i); // ok]]>
|
||||
</programlisting>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1593,7 +1597,7 @@ For example, using this syntax the <literal>if_then</literal> example above
|
||||
can be written as:
|
||||
<programlisting>
|
||||
<![CDATA[for_each(a.begin(), a.end(),
|
||||
if(_1 % 2 == 0)[ cout << _1 ])]]>
|
||||
if_(_1 % 2 == 0)[ cout << _1 ])]]>
|
||||
</programlisting>
|
||||
|
||||
As more experience is gained, we may end up deprecating one or the other
|
||||
@@ -1858,7 +1862,7 @@ and the effect of evaluating that expression.
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>destructor()(pa)</literal></entry>
|
||||
<entry><literal>pa.->A()</literal>, where <literal>pa</literal> is of type <literal>A*</literal></entry>
|
||||
<entry><literal>pa->~A()</literal>, where <literal>pa</literal> is of type <literal>A*</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>new_ptr<T>()(<parameter>arg_list</parameter>)</literal></entry>
|
||||
@@ -3034,8 +3038,8 @@ For example:
|
||||
<![CDATA[boost::function<int(int, int)> f = _1 + _2;
|
||||
boost::function<int&(int&)> g = (_1 += 10);
|
||||
int i = 1, j = 2;
|
||||
f(i); // returns 3
|
||||
g(i); // sets i to = 11;]]>
|
||||
f(i, j); // returns 3
|
||||
g(i); // sets i to = 11;]]>
|
||||
</programlisting>
|
||||
|
||||
The return and parameter types of the wrapped function object must be written explicilty as the template argument to the wrapper template <literal>boost::function</literal>; even when lambda functors, which otherwise have generic parameters, are wrapped.
|
||||
@@ -3350,6 +3354,37 @@ was dropped.
|
||||
<bibliomisc><ulink url="http://www.oonumerics.org/tmpw01/">www.oonumerics.org/tmpw01/</ulink></bibliomisc>
|
||||
</biblioentry>
|
||||
|
||||
<biblioentry id="cit:jarvi:03">
|
||||
<abbrev>Jär03</abbrev>
|
||||
|
||||
<articleinfo>
|
||||
|
||||
<author>
|
||||
<surname>Järvi</surname>
|
||||
<firstname>Jaakko</firstname>
|
||||
</author>
|
||||
|
||||
<author>
|
||||
<firstname>Gary</firstname>
|
||||
<surname>Powell</surname>
|
||||
</author>
|
||||
|
||||
<author>
|
||||
<firstname>Andrew</firstname>
|
||||
<surname>Lumsdaine</surname>
|
||||
</author>
|
||||
<title>The Lambda Library : unnamed functions in C++</title>
|
||||
|
||||
</articleinfo>
|
||||
|
||||
<title>Software - Practice and Expreience</title>
|
||||
<volumenum>33:259-291</volumenum>
|
||||
|
||||
|
||||
<pubdate>2003</pubdate>
|
||||
</biblioentry>
|
||||
|
||||
|
||||
<biblioentry id="cit:boost::tuple">
|
||||
<abbrev>tuple</abbrev>
|
||||
<title>The Boost Tuple Library</title>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
The Boost Lambda Library is free software; Permission to copy,
|
||||
use, modify and distribute this software and its documentation is granted, provided this copyright
|
||||
notice appears in all copies.
|
||||
</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="index.html#introduction">In a nutshell</a></dt><dt>2. <a href="ar01s02.html">Getting Started</a></dt><dd><dl><dt>2.1. <a href="ar01s02.html#id2790118">Installing the library</a></dt><dt>2.2. <a href="ar01s02.html#id2741945">Conventions used in this document</a></dt></dl></dd><dt>3. <a href="ar01s03.html">Introduction</a></dt><dd><dl><dt>3.1. <a href="ar01s03.html#id2741999">Motivation</a></dt><dt>3.2. <a href="ar01s03.html#id2742792">Introduction to lambda expressions</a></dt></dl></dd><dt>4. <a href="ar01s04.html">Using the library</a></dt><dd><dl><dt>4.1. <a href="ar01s04.html#sect:introductory_examples">Introductory Examples</a></dt><dt>4.2. <a href="ar01s04.html#sect:parameter_and_return_types">Parameter and return types of lambda functors</a></dt><dt>4.3. <a href="ar01s04.html#sect:actual_arguments_to_lambda_functors">About actual arguments to lambda functors</a></dt><dt>4.4. <a href="ar01s04.html#sect:storing_bound_arguments">Storing bound arguments in lambda functions</a></dt></dl></dd><dt>5. <a href="ar01s05.html">Lambda expressions in details</a></dt><dd><dl><dt>5.1. <a href="ar01s05.html#sect:placeholders">Placeholders</a></dt><dt>5.2. <a href="ar01s05.html#sect:operator_expressions">Operator expressions</a></dt><dt>5.3. <a href="ar01s05.html#sect:bind_expressions">Bind expressions</a></dt><dt>5.4. <a href="ar01s05.html#sect:overriding_deduced_return_type">Overriding the deduced return type</a></dt><dt>5.5. <a href="ar01s05.html#sect:delaying_constants_and_variables">Delaying constants and variables</a></dt><dt>5.6. <a href="ar01s05.html#sect:lambda_expressions_for_control_structures">Lambda expressions for control structures</a></dt><dt>5.7. <a href="ar01s05.html#sect:exceptions">Exceptions</a></dt><dt>5.8. <a href="ar01s05.html#sect:construction_and_destruction">Construction and destruction</a></dt><dt>5.9. <a href="ar01s05.html#id2805484">Special lambda expressions</a></dt><dt>5.10. <a href="ar01s05.html#id2806057">Casts, sizeof and typeid</a></dt><dt>5.11. <a href="ar01s05.html#sect:nested_stl_algorithms">Nesting STL algorithm invocations</a></dt></dl></dd><dt>6. <a href="ar01s06.html">Extending return type deduction system</a></dt><dt>7. <a href="ar01s07.html">Practical considerations</a></dt><dd><dl><dt>7.1. <a href="ar01s07.html#id2807572">Performance</a></dt><dt>7.2. <a href="ar01s07.html#id2808065">About compiling</a></dt><dt>7.3. <a href="ar01s07.html#id2808126">Portability</a></dt></dl></dd><dt>8. <a href="ar01s08.html">Relation to other Boost libraries</a></dt><dd><dl><dt>8.1. <a href="ar01s08.html#id2808518">Boost Function</a></dt><dt>8.2. <a href="ar01s08.html#id2808622">Boost Bind</a></dt></dl></dd><dt>9. <a href="ar01s09.html">Contributors</a></dt><dt>A. <a href="apa.html">Rationale for some of the design decisions</a></dt><dd><dl><dt>1. <a href="apa.html#sect:why_weak_arity">
|
||||
</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="index.html#introduction">In a nutshell</a></dt><dt>2. <a href="ar01s02.html">Getting Started</a></dt><dd><dl><dt>2.1. <a href="ar01s02.html#id2790118">Installing the library</a></dt><dt>2.2. <a href="ar01s02.html#id2741945">Conventions used in this document</a></dt></dl></dd><dt>3. <a href="ar01s03.html">Introduction</a></dt><dd><dl><dt>3.1. <a href="ar01s03.html#id2741999">Motivation</a></dt><dt>3.2. <a href="ar01s03.html#id2742792">Introduction to lambda expressions</a></dt></dl></dd><dt>4. <a href="ar01s04.html">Using the library</a></dt><dd><dl><dt>4.1. <a href="ar01s04.html#sect:introductory_examples">Introductory Examples</a></dt><dt>4.2. <a href="ar01s04.html#sect:parameter_and_return_types">Parameter and return types of lambda functors</a></dt><dt>4.3. <a href="ar01s04.html#sect:actual_arguments_to_lambda_functors">About actual arguments to lambda functors</a></dt><dt>4.4. <a href="ar01s04.html#sect:storing_bound_arguments">Storing bound arguments in lambda functions</a></dt></dl></dd><dt>5. <a href="ar01s05.html">Lambda expressions in details</a></dt><dd><dl><dt>5.1. <a href="ar01s05.html#sect:placeholders">Placeholders</a></dt><dt>5.2. <a href="ar01s05.html#sect:operator_expressions">Operator expressions</a></dt><dt>5.3. <a href="ar01s05.html#sect:bind_expressions">Bind expressions</a></dt><dt>5.4. <a href="ar01s05.html#sect:overriding_deduced_return_type">Overriding the deduced return type</a></dt><dt>5.5. <a href="ar01s05.html#sect:delaying_constants_and_variables">Delaying constants and variables</a></dt><dt>5.6. <a href="ar01s05.html#sect:lambda_expressions_for_control_structures">Lambda expressions for control structures</a></dt><dt>5.7. <a href="ar01s05.html#sect:exceptions">Exceptions</a></dt><dt>5.8. <a href="ar01s05.html#sect:construction_and_destruction">Construction and destruction</a></dt><dt>5.9. <a href="ar01s05.html#id2805507">Special lambda expressions</a></dt><dt>5.10. <a href="ar01s05.html#id2806080">Casts, sizeof and typeid</a></dt><dt>5.11. <a href="ar01s05.html#sect:nested_stl_algorithms">Nesting STL algorithm invocations</a></dt></dl></dd><dt>6. <a href="ar01s06.html">Extending return type deduction system</a></dt><dt>7. <a href="ar01s07.html">Practical considerations</a></dt><dd><dl><dt>7.1. <a href="ar01s07.html#id2807595">Performance</a></dt><dt>7.2. <a href="ar01s07.html#id2808087">About compiling</a></dt><dt>7.3. <a href="ar01s07.html#id2808149">Portability</a></dt></dl></dd><dt>8. <a href="ar01s08.html">Relation to other Boost libraries</a></dt><dd><dl><dt>8.1. <a href="ar01s08.html#id2808540">Boost Function</a></dt><dt>8.2. <a href="ar01s08.html#id2808644">Boost Bind</a></dt></dl></dd><dt>9. <a href="ar01s09.html">Contributors</a></dt><dt>A. <a href="apa.html">Rationale for some of the design decisions</a></dt><dd><dl><dt>1. <a href="apa.html#sect:why_weak_arity">
|
||||
Lambda functor arity
|
||||
</a></dt></dl></dd><dt><a href="bi01.html">Bibliography</a></dt></dl></div><a href="lambda_docs_as_one_file.html" target="_top">Documentation as a one big HTML-file</a><div class="section"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="introduction"></a>1. In a nutshell</h2></div></div><p>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,9 +38,9 @@ struct for_each {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::for_each(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -55,9 +55,9 @@ struct find {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, const C& c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::find(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -73,9 +73,9 @@ struct find_if {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::find_if(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -90,14 +90,14 @@ struct find_end {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return ::std::find_end(a, b, c, d); }
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
A
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return ::std::find_end(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -113,14 +113,14 @@ struct find_first_of {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return ::std::find_first_of(a, b, c, d); }
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
A
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return ::std::find_first_of(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -136,14 +136,14 @@ struct adjacent_find {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::adjacent_find(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::adjacent_find(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -161,10 +161,10 @@ struct count {
|
||||
>::difference_type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A, class C >
|
||||
typename ::std::iterator_traits<A>::difference_type
|
||||
operator()(A a, B b) const
|
||||
{ return ::std::count(a, b); }
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::count(a, b, c); }
|
||||
};
|
||||
|
||||
// count_if ---------------------------------
|
||||
@@ -180,9 +180,9 @@ struct count_if {
|
||||
>::difference_type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
typename ::std::iterator_traits<A>::difference_type
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::count_if(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -195,21 +195,25 @@ struct mismatch {
|
||||
struct sig {
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::tuples::element<1, Args>::type
|
||||
>::type element_type;
|
||||
>::type element1_type;
|
||||
|
||||
typedef ::std::pair< element_type, element_type > type;
|
||||
typedef typename boost::remove_const<
|
||||
typename boost::tuples::element<3, Args>::type
|
||||
>::type element2_type;
|
||||
|
||||
typedef ::std::pair< element1_type, element2_type > type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
::std::pair<A,A>
|
||||
operator()(A a, B b) const
|
||||
{ return ::std::mismatch(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
::std::pair<A,A>
|
||||
operator()(A a, B b, C c) const
|
||||
template <class A, class C >
|
||||
::std::pair<A,C>
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::mismatch(a, b, c); }
|
||||
|
||||
template <class A, class C, class D>
|
||||
::std::pair<A,C>
|
||||
operator()(A a, A b, C c, D d) const
|
||||
{ return ::std::mismatch(a, b, c, d); }
|
||||
|
||||
};
|
||||
|
||||
// equal ---------------------------------
|
||||
@@ -221,14 +225,14 @@ struct equal {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
bool
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::equal(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, D d) const
|
||||
{ return ::std::equal(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -244,14 +248,14 @@ struct search {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return std::search(a, b, c, d);}
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
A
|
||||
operator()(A a, B b, C c, D d, E e)
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::search(a, b, c, d, e);}
|
||||
|
||||
};
|
||||
@@ -267,9 +271,9 @@ struct copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::copy(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -285,9 +289,9 @@ struct copy_backward {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::copy_backward(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -301,9 +305,9 @@ struct swap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::swap(a, b); }
|
||||
|
||||
};
|
||||
@@ -319,9 +323,9 @@ struct swap_ranges {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::swap_ranges(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -335,9 +339,9 @@ struct iter_swap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::iter_swap(a, b); }
|
||||
|
||||
};
|
||||
@@ -357,14 +361,14 @@ struct transform {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, D d) const
|
||||
{ return std::transform(a, b, c, d);}
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class D, class E>
|
||||
D
|
||||
operator()(A a, B b, C c, D d, E e)
|
||||
operator()(A a, A b, C c, D d, E e) const
|
||||
{ return std::transform(a, b, c, d, e);}
|
||||
|
||||
};
|
||||
@@ -378,9 +382,9 @@ struct replace {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, const C& c, const C& d) const
|
||||
{ ::std::replace(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -394,9 +398,9 @@ struct replace_if {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
void
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, const D& d) const
|
||||
{ ::std::replace_if(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -412,9 +416,9 @@ struct replace_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class D>
|
||||
C
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, const D& d, const D& e) const
|
||||
{ return ::std::replace_copy(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -430,9 +434,9 @@ struct replace_copy_if {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class D, class E>
|
||||
C
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, D d, const E& e) const
|
||||
{ return ::std::replace_copy_if(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -446,9 +450,9 @@ struct fill {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ ::std::fill(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -464,7 +468,7 @@ struct fill_n {
|
||||
|
||||
template <class A, class B, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, B b, const C& c) const
|
||||
{ ::std::fill_n(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -478,9 +482,9 @@ struct generate {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::generate(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -512,9 +516,9 @@ struct remove {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::remove(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -529,9 +533,9 @@ struct remove_if {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::remove_if(a, b, c); }
|
||||
};
|
||||
|
||||
@@ -546,9 +550,9 @@ struct remove_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D >
|
||||
template <class A, class C, class D >
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, const D& d) const
|
||||
{ return ::std::remove_copy(a, b, c, d); }
|
||||
};
|
||||
|
||||
@@ -563,9 +567,9 @@ struct remove_copy_if {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D >
|
||||
template <class A, class C, class D >
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, D d) const
|
||||
{ return ::std::remove_copy_if(a, b, c, d); }
|
||||
};
|
||||
|
||||
@@ -580,14 +584,14 @@ struct unique {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::unique(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::unique(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -603,14 +607,14 @@ struct unique_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::unique_copy(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, D d) const
|
||||
{ return ::std::unique_copy(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -624,9 +628,9 @@ struct reverse {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::reverse(a, b); }
|
||||
|
||||
};
|
||||
@@ -642,9 +646,9 @@ struct reverse_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
C
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::reverse_copy(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -658,9 +662,9 @@ struct rotate {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, A c) const
|
||||
{ ::std::rotate(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -676,9 +680,9 @@ struct rotate_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
template <class A, class D>
|
||||
D
|
||||
operator()(A a, A b, A c, D d) const
|
||||
{ return ::std::rotate_copy(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -692,14 +696,14 @@ struct random_shuffle {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::random_shuffle(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ ::std::random_shuffle(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -716,9 +720,9 @@ struct partition {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::partition(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -734,9 +738,9 @@ struct stable_partition {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::stable_partition(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -750,14 +754,14 @@ struct sort {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::sort(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::sort(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -771,14 +775,14 @@ struct stable_sort {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::stable_sort(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::stable_sort(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -792,14 +796,14 @@ struct partial_sort {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, A c) const
|
||||
{ ::std::partial_sort(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class D>
|
||||
void
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, A c, D d) const
|
||||
{ ::std::partial_sort(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -815,14 +819,14 @@ struct partial_sort_copy {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D >
|
||||
template <class A, class C>
|
||||
C
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return ::std::partial_sort_copy(a, b, c, d); }
|
||||
|
||||
template <class A, class B, class C, class D, class E >
|
||||
template <class A, class C, class E >
|
||||
C
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return ::std::partial_sort_copy(a, b, c, d, e); }
|
||||
};
|
||||
|
||||
@@ -835,14 +839,14 @@ struct nth_element {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, A c) const
|
||||
{ ::std::nth_element(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class D>
|
||||
void
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, A c, D d) const
|
||||
{ ::std::nth_element(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -858,14 +862,14 @@ struct lower_bound {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::lower_bound(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
A
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, const C& c, D d) const
|
||||
{ return ::std::lower_bound(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -881,14 +885,14 @@ struct upper_bound {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::upper_bound(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
A
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, const C& c, D d) const
|
||||
{ return ::std::upper_bound(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -906,14 +910,14 @@ struct equal_range {
|
||||
typedef ::std::pair< element_type, element_type > type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
::std::pair<A,A>
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::equal_range(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
::std::pair<A,A>
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, const C& c, D d) const
|
||||
{ return ::std::equal_range(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -927,14 +931,14 @@ struct binary_search {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
bool
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, const C& c) const
|
||||
{ return ::std::binary_search(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C, class D>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, const C& c, D d) const
|
||||
{ return ::std::binary_search(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -950,14 +954,14 @@ struct merge {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::merge(a, b, c, d, e);}
|
||||
|
||||
template <class A, class B, class C, class D, class E, class F>
|
||||
template <class A, class C, class E, class F>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e, F f)
|
||||
operator()(A a, A b, C c, C d, E e, F f) const
|
||||
{ return std::merge(a, b, c, d, e, f);}
|
||||
|
||||
};
|
||||
@@ -971,14 +975,14 @@ struct inplace_merge {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, A c) const
|
||||
{ ::std::inplace_merge(a, b, c); }
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class D>
|
||||
void
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, A c, D d) const
|
||||
{ ::std::inplace_merge(a, b, c, d); }
|
||||
|
||||
};
|
||||
@@ -992,14 +996,14 @@ struct includes {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return ::std::includes(a, b, c, d); }
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return ::std::includes(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -1015,14 +1019,14 @@ struct set_union {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::set_union(a, b, c, d, e);}
|
||||
|
||||
template <class A, class B, class C, class D, class E, class F>
|
||||
template <class A, class C, class E, class F>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e, F f)
|
||||
operator()(A a, A b, C c, C d, E e, F f) const
|
||||
{ return std::set_union(a, b, c, d, e, f);}
|
||||
|
||||
};
|
||||
@@ -1038,14 +1042,14 @@ struct set_intersection {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::set_intersection(a, b, c, d, e);}
|
||||
|
||||
template <class A, class B, class C, class D, class E, class F>
|
||||
template <class A, class C, class E, class F>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e, F f)
|
||||
operator()(A a, A b, C c, C d, E e, F f) const
|
||||
{ return std::set_intersection(a, b, c, d, e, f);}
|
||||
|
||||
};
|
||||
@@ -1061,14 +1065,14 @@ struct set_difference {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::set_difference(a, b, c, d, e);}
|
||||
|
||||
template <class A, class B, class C, class D, class E, class F>
|
||||
template <class A, class C, class E, class F>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e, F f)
|
||||
operator()(A a, A b, C c, C d, E e, F f) const
|
||||
{ return std::set_difference(a, b, c, d, e, f);}
|
||||
|
||||
};
|
||||
@@ -1085,14 +1089,14 @@ struct set_symmetric_difference {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return std::set_symmetric_difference(a, b, c, d, e);}
|
||||
|
||||
template <class A, class B, class C, class D, class E, class F>
|
||||
template <class A, class C, class E, class F>
|
||||
E
|
||||
operator()(A a, B b, C c, D d, E e, F f)
|
||||
operator()(A a, A b, C c, C d, E e, F f) const
|
||||
{ return std::set_symmetric_difference(a, b, c, d, e, f);}
|
||||
|
||||
};
|
||||
@@ -1106,14 +1110,14 @@ struct push_heap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::push_heap(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::push_heap(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1127,14 +1131,14 @@ struct pop_heap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::pop_heap(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::pop_heap(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1149,14 +1153,14 @@ struct make_heap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::make_heap(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::make_heap(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1170,14 +1174,14 @@ struct sort_heap {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <class A, class B>
|
||||
template <class A>
|
||||
void
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ ::std::sort_heap(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
void
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ ::std::sort_heap(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1193,14 +1197,14 @@ struct min {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(const A& a, const A& b) const
|
||||
{ return ::std::min(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(const A& a, const A& b, C c) const
|
||||
{ return ::std::min(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1216,14 +1220,14 @@ struct max {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(const A& a, const A& b) const
|
||||
{ return ::std::max(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(const A& a, const A& b, C c) const
|
||||
{ return ::std::max(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1237,14 +1241,14 @@ struct min_element {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::min_element(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::min_element(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1260,14 +1264,14 @@ struct max_element {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
A
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::max_element(a, b); }
|
||||
|
||||
template <class A, class B, class C>
|
||||
template <class A, class C>
|
||||
A
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::max_element(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1282,14 +1286,14 @@ struct lexicographical_compare {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B, class C, class D>
|
||||
template <class A, class C>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d) const
|
||||
operator()(A a, A b, C c, C d) const
|
||||
{ return ::std::lexicographical_compare(a, b, c, d); }
|
||||
|
||||
template <class A, class B, class C, class D, class E>
|
||||
template <class A, class C, class E>
|
||||
bool
|
||||
operator()(A a, B b, C c, D d, E e) const
|
||||
operator()(A a, A b, C c, C d, E e) const
|
||||
{ return ::std::lexicographical_compare(a, b, c, d, e); }
|
||||
|
||||
};
|
||||
@@ -1303,14 +1307,14 @@ struct next_permutation {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
bool
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::next_permutation(a, b); }
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
bool
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::next_permutation(a, b, c); }
|
||||
|
||||
};
|
||||
@@ -1324,14 +1328,14 @@ struct prev_permutation {
|
||||
typedef bool type;
|
||||
};
|
||||
|
||||
template <class A, class B >
|
||||
template <class A>
|
||||
bool
|
||||
operator()(A a, B b) const
|
||||
operator()(A a, A b) const
|
||||
{ return ::std::prev_permutation(a, b); }
|
||||
|
||||
template <class A, class B, class C >
|
||||
template <class A, class C >
|
||||
bool
|
||||
operator()(A a, B b, C c) const
|
||||
operator()(A a, A b, C c) const
|
||||
{ return ::std::prev_permutation(a, b, c); }
|
||||
|
||||
};
|
||||
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
|
||||
|
||||
template<class RET, CALL_TEMPLATE_ARGS> RET call(CALL_FORMAL_ARGS) const {
|
||||
CALL_USE_ARGS;
|
||||
return CALL_USE_ARGS;
|
||||
}
|
||||
|
||||
template<class SigArgs> struct sig { typedef void type; };
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "boost/lambda/detail/is_instance_of.hpp"
|
||||
#include "boost/type_traits/same_traits.hpp"
|
||||
|
||||
#include "boost/indirect_reference.hpp"
|
||||
|
||||
#include <cstddef> // needed for the ptrdiff_t
|
||||
#include <iosfwd> // for istream and ostream
|
||||
|
||||
@@ -221,7 +223,7 @@ namespace detail {
|
||||
|
||||
// A is a nonreference type
|
||||
template <class A> struct contentsof_type {
|
||||
typedef typename std::iterator_traits<A>::reference type;
|
||||
typedef typename boost::indirect_reference<A>::type type;
|
||||
};
|
||||
|
||||
// this is since the nullary () in lambda_functor is always instantiated
|
||||
@@ -492,7 +494,6 @@ struct promotion_of_unsigned_int
|
||||
{
|
||||
typedef
|
||||
detail::IF<sizeof(long) <= sizeof(unsigned int),
|
||||
// I had the logic reversed but ">" messes up the parsing.
|
||||
unsigned long,
|
||||
long>::RET type;
|
||||
};
|
||||
@@ -866,10 +867,20 @@ namespace std {
|
||||
template <class Key, class T, class Cmp, class Allocator> class map;
|
||||
template <class Key, class T, class Cmp, class Allocator> class multimap;
|
||||
template <class T, class Allocator> class vector;
|
||||
template <class T, class Allocator> class deque;
|
||||
template <class Char, class Traits, class Allocator> class basic_string;
|
||||
}
|
||||
|
||||
// The GCC 2.95.x uses a non-conformant deque
|
||||
#if BOOST_WORKAROUND(__GNUC__, == 2) && __GNUC_MINOR__ <= 96
|
||||
#include <deque>
|
||||
#else
|
||||
|
||||
namespace std {
|
||||
template <class T, class Allocator> class deque;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace lambda {
|
||||
|
||||
@@ -27,22 +27,31 @@ namespace lambda {
|
||||
#error "Multiple defines of BOOST_LAMBDA_BE1"
|
||||
#endif
|
||||
|
||||
// For all BOOSTA_LAMBDA_BE* macros:
|
||||
|
||||
// CONSTA must be either 'A' or 'const A'
|
||||
// CONSTB must be either 'B' or 'const B'
|
||||
|
||||
// It is stupid to have the names A and B as macro arguments, but it avoids
|
||||
// the need to pass in emtpy macro arguments, which gives warnings on some
|
||||
// compilers
|
||||
|
||||
#define BOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONVERSION) \
|
||||
template<class Arg, class B> \
|
||||
inline const \
|
||||
lambda_functor< \
|
||||
lambda_functor_base< \
|
||||
ACTION, \
|
||||
tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB B>::type> \
|
||||
tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type> \
|
||||
> \
|
||||
> \
|
||||
OPER_NAME (const lambda_functor<Arg>& a, CONSTB B& b) { \
|
||||
OPER_NAME (const lambda_functor<Arg>& a, CONSTB& b) { \
|
||||
return \
|
||||
lambda_functor_base< \
|
||||
ACTION, \
|
||||
tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB B>::type> \
|
||||
tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type> \
|
||||
> \
|
||||
(tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB B>::type>(a, b)); \
|
||||
(tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type>(a, b)); \
|
||||
}
|
||||
|
||||
|
||||
@@ -56,16 +65,16 @@ inline const \
|
||||
lambda_functor< \
|
||||
lambda_functor_base< \
|
||||
ACTION, \
|
||||
tuple<typename CONVERSION <CONSTA A>::type, lambda_functor<Arg> > \
|
||||
tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \
|
||||
> \
|
||||
> \
|
||||
OPER_NAME (CONSTA A& a, const lambda_functor<Arg>& b) { \
|
||||
OPER_NAME (CONSTA& a, const lambda_functor<Arg>& b) { \
|
||||
return \
|
||||
lambda_functor_base< \
|
||||
ACTION, \
|
||||
tuple<typename CONVERSION <CONSTA A>::type, lambda_functor<Arg> > \
|
||||
tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> > \
|
||||
> \
|
||||
(tuple<typename CONVERSION <CONSTA A>::type, lambda_functor<Arg> >(a, b)); \
|
||||
(tuple<typename CONVERSION <CONSTA>::type, lambda_functor<Arg> >(a, b)); \
|
||||
}
|
||||
|
||||
|
||||
@@ -100,36 +109,37 @@ BOOST_LAMBDA_BE1(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \
|
||||
BOOST_LAMBDA_BE2(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION) \
|
||||
BOOST_LAMBDA_BE3(OPER_NAME, ACTION, CONSTA, CONSTB, CONST_CONVERSION)
|
||||
|
||||
#define BOOST_LAMBDA_EMPTY()
|
||||
|
||||
BOOST_LAMBDA_BE(operator+, arithmetic_action<plus_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator-, arithmetic_action<minus_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator*, arithmetic_action<multiply_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator/, arithmetic_action<divide_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator%, arithmetic_action<remainder_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<<, bitwise_action<leftshift_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>>, bitwise_action<rightshift_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator&, bitwise_action<and_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator|, bitwise_action<or_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator^, bitwise_action<xor_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator&&, logical_action<and_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator||, logical_action<or_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<, relational_action<less_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>, relational_action<greater_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<=, relational_action<lessorequal_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>=, relational_action<greaterorequal_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator==, relational_action<equal_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator!=, relational_action<notequal_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator+, arithmetic_action<plus_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator-, arithmetic_action<minus_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator*, arithmetic_action<multiply_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator/, arithmetic_action<divide_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator%, arithmetic_action<remainder_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<<, bitwise_action<leftshift_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>>, bitwise_action<rightshift_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator&, bitwise_action<and_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator|, bitwise_action<or_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator^, bitwise_action<xor_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator&&, logical_action<and_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator||, logical_action<or_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<, relational_action<less_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>, relational_action<greater_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator<=, relational_action<lessorequal_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator>=, relational_action<greaterorequal_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator==, relational_action<equal_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE(operator!=, relational_action<notequal_action>, const A, const B, const_copy_argument)
|
||||
|
||||
BOOST_LAMBDA_BE(operator+=, arithmetic_assignment_action<plus_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator-=, arithmetic_assignment_action<minus_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator*=, arithmetic_assignment_action<multiply_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator/=, arithmetic_assignment_action<divide_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator%=, arithmetic_assignment_action<remainder_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator<<=, bitwise_assignment_action<leftshift_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator>>=, bitwise_assignment_action<rightshift_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator&=, bitwise_assignment_action<and_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator|=, bitwise_assignment_action<or_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator^=, bitwise_assignment_action<xor_action>, , const, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator+=, arithmetic_assignment_action<plus_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator-=, arithmetic_assignment_action<minus_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator*=, arithmetic_assignment_action<multiply_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator/=, arithmetic_assignment_action<divide_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator%=, arithmetic_assignment_action<remainder_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator<<=, bitwise_assignment_action<leftshift_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator>>=, bitwise_assignment_action<rightshift_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator&=, bitwise_assignment_action<and_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator|=, bitwise_assignment_action<or_action>, A, const B, reference_argument)
|
||||
BOOST_LAMBDA_BE(operator^=, bitwise_assignment_action<xor_action>, A, const B, reference_argument)
|
||||
|
||||
|
||||
// A special trick for comma operator for correct preprocessing
|
||||
@@ -139,9 +149,9 @@ BOOST_LAMBDA_BE(operator^=, bitwise_assignment_action<xor_action>, , const, refe
|
||||
|
||||
#define BOOST_LAMBDA_COMMA_OPERATOR_NAME operator,
|
||||
|
||||
BOOST_LAMBDA_BE1(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE2(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE3(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const, const, const_copy_argument)
|
||||
BOOST_LAMBDA_BE1(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE2(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
|
||||
BOOST_LAMBDA_BE3(BOOST_LAMBDA_COMMA_OPERATOR_NAME, other_action<comma_action>, const A, const B, const_copy_argument)
|
||||
|
||||
|
||||
|
||||
@@ -197,8 +207,8 @@ template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default {
|
||||
|
||||
} // detail
|
||||
|
||||
BOOST_LAMBDA_BE2(operator<<, bitwise_action< leftshift_action>, , const, detail::convert_ostream_to_ref_others_to_c_plain_by_default)
|
||||
BOOST_LAMBDA_BE2(operator>>, bitwise_action< rightshift_action>, , const, detail::convert_istream_to_ref_others_to_c_plain_by_default)
|
||||
BOOST_LAMBDA_BE2(operator<<, bitwise_action< leftshift_action>, A, const B, detail::convert_ostream_to_ref_others_to_c_plain_by_default)
|
||||
BOOST_LAMBDA_BE2(operator>>, bitwise_action< rightshift_action>, A, const B, detail::convert_istream_to_ref_others_to_c_plain_by_default)
|
||||
|
||||
|
||||
// special case for io_manipulators.
|
||||
@@ -253,17 +263,17 @@ operator>>(const lambda_functor<Arg>& a, Ret(&b)(ManipArg))
|
||||
#error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E1"
|
||||
#endif
|
||||
|
||||
#define BOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONST) \
|
||||
#define BOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONSTB) \
|
||||
template<class Arg, int N, class B> \
|
||||
inline const \
|
||||
lambda_functor< \
|
||||
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONST B(&)[N]> > \
|
||||
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
|
||||
> \
|
||||
OPER_NAME (const lambda_functor<Arg>& a, CONST B(&b)[N]) \
|
||||
OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \
|
||||
{ \
|
||||
return lambda_functor< \
|
||||
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONST B(&)[N]> > \
|
||||
>(tuple<lambda_functor<Arg>, CONST B(&)[N]>(a, b)); \
|
||||
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
|
||||
>(tuple<lambda_functor<Arg>, CONSTB(&)[N]>(a, b)); \
|
||||
}
|
||||
|
||||
|
||||
@@ -271,31 +281,31 @@ OPER_NAME (const lambda_functor<Arg>& a, CONST B(&b)[N]) \
|
||||
#error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E2"
|
||||
#endif
|
||||
|
||||
#define BOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONST) \
|
||||
#define BOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONSTA) \
|
||||
template<int N, class A, class Arg> \
|
||||
inline const \
|
||||
lambda_functor< \
|
||||
lambda_functor_base<ACTION, tuple<CONST A(&)[N], lambda_functor<Arg> > > \
|
||||
lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
|
||||
> \
|
||||
OPER_NAME (CONST A(&a)[N], const lambda_functor<Arg>& b) \
|
||||
OPER_NAME (CONSTA(&a)[N], const lambda_functor<Arg>& b) \
|
||||
{ \
|
||||
return \
|
||||
lambda_functor_base<ACTION, tuple<CONST A(&)[N], lambda_functor<Arg> > > \
|
||||
(tuple<CONST A(&)[N], lambda_functor<Arg> >(a, b)); \
|
||||
lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
|
||||
(tuple<CONSTA(&)[N], lambda_functor<Arg> >(a, b)); \
|
||||
}
|
||||
|
||||
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>,)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>,)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>,const)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>,const)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>, B)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>, A)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator+, arithmetic_action<plus_action>,const B)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator+, arithmetic_action<plus_action>,const A)
|
||||
|
||||
|
||||
//BOOST_LAMBDA_PTR_ARITHMETIC_E1(operator-, arithmetic_action<minus_action>)
|
||||
// This is not needed, since the result of ptr-ptr is an rvalue anyway
|
||||
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, )
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, const)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, A)
|
||||
BOOST_LAMBDA_PTR_ARITHMETIC_E2(operator-, arithmetic_action<minus_action>, const A)
|
||||
|
||||
|
||||
#undef BOOST_LAMBDA_BE1
|
||||
|
||||
@@ -257,7 +257,7 @@ const_parameters(const lambda_functor<Arg>& lf)
|
||||
// the wrapped lambda functor is evaluated, but we just don't do anything
|
||||
// with the result.
|
||||
struct voidifier_action {
|
||||
template<class Ret, class A> static Ret apply(A&) {}
|
||||
template<class Ret, class A> static void apply(A&) {}
|
||||
};
|
||||
|
||||
template<class Args> struct return_type_N<voidifier_action, Args> {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#ifndef BOOST_LAMBDA_RETURN_TYPE_TRAITS_HPP
|
||||
#define BOOST_LAMBDA_RETURN_TYPE_TRAITS_HPP
|
||||
|
||||
#include "boost/mpl/aux_/has_xxx.hpp"
|
||||
|
||||
#include <cstddef> // needed for the ptrdiff_t
|
||||
|
||||
namespace boost {
|
||||
@@ -239,6 +241,25 @@ struct return_type_N<function_action<I, Ret>, Args> {
|
||||
typedef Ret type;
|
||||
};
|
||||
|
||||
// ::result_type support
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
||||
|
||||
template<class F> struct get_result_type
|
||||
{
|
||||
typedef typename F::result_type type;
|
||||
};
|
||||
|
||||
template<class F, class A> struct get_sig
|
||||
{
|
||||
typedef typename function_adaptor<F>::template sig<A>::type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Ret is detail::unspecified, so try to deduce return type
|
||||
template<int I, class Args>
|
||||
struct return_type_N<function_action<I, detail::unspecified>, Args > {
|
||||
@@ -251,7 +272,11 @@ struct return_type_N<function_action<I, detail::unspecified>, Args > {
|
||||
public:
|
||||
// pass the function to function_adaptor, and get the return type from
|
||||
// that
|
||||
typedef typename function_adaptor<plain_Func>::template sig<Args>::type type;
|
||||
typedef typename detail::IF<
|
||||
detail::has_result_type<plain_Func>::value,
|
||||
detail::get_result_type<plain_Func>,
|
||||
detail::get_sig<plain_Func, Args>
|
||||
>::RET::type type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ unit-test is_instance_of_test
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test algortihm_test
|
||||
: algorithm_test.cpp
|
||||
<lib>../../test/build/test_exec_monitor
|
||||
: <sysinclude>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
unit-test operator_tests_simple
|
||||
: operator_tests_simple.cpp
|
||||
<lib>../../test/build/test_exec_monitor
|
||||
|
||||
66
test/algorithm_test.cpp
Normal file
66
test/algorithm_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// bll_and_function.cpp - The Boost Lambda Library -----------------------
|
||||
//
|
||||
// Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
|
||||
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
|
||||
//
|
||||
// Permission to copy, use, sell and distribute this software is granted
|
||||
// provided this copyright notice appears in all copies.
|
||||
// Permission to modify the code and to distribute modified code is granted
|
||||
// provided this copyright notice appears in all copies, and a notice
|
||||
// that the code was modified is included with the copyright notice.
|
||||
//
|
||||
// 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 www.boost.org
|
||||
|
||||
// test using BLL and boost::function
|
||||
|
||||
//#include <boost/test/minimal.hpp> // see "Header Implementation Option"
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include "boost/lambda/lambda.hpp"
|
||||
#include "boost/lambda/bind.hpp"
|
||||
#include "boost/lambda/algorithm.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
void test_foreach() {
|
||||
using namespace boost::lambda;
|
||||
|
||||
int a[10][20];
|
||||
int sum = 0;
|
||||
|
||||
std::for_each(a, a + 10,
|
||||
bind(ll::for_each(), _1, _1 + 20,
|
||||
protect((_1 = var(sum), ++var(sum)))));
|
||||
|
||||
sum = 0;
|
||||
std::for_each(a, a + 10,
|
||||
bind(ll::for_each(), _1, _1 + 20,
|
||||
protect((sum += _1))));
|
||||
|
||||
BOOST_TEST(sum == (199 + 1)/ 2 * 199);
|
||||
}
|
||||
|
||||
// More tests needed (for all algorithms)
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
|
||||
test_foreach();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user