2
0
mirror of https://github.com/boostorg/lambda.git synced 2026-01-21 04:52:25 +00:00

Compare commits

...

14 Commits

Author SHA1 Message Date
nobody
1543b68314 This commit was manufactured by cvs2svn to create tag
'Version_1_34_1_RC3'.

[SVN r38225]
2007-07-16 13:13:26 +00:00
Daniel James
b112fb9254 Fix a link.
[SVN r36651]
2007-01-07 22:42:25 +00:00
Jaakko Järvi
13ec0c5bbc fixed omission
[SVN r36201]
2006-11-29 19:28:48 +00:00
Jaakko Järvi
29ab5a2814 fixed bug 1444052
[SVN r36200]
2006-11-29 19:21:46 +00:00
Beman Dawes
a0cfe43611 Merged copyright and license addition
[SVN r35907]
2006-11-07 19:27:00 +00:00
Rene Rivera
fe858cf734 Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
nobody
b3120233dc This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
Jaakko Järvi
24e8602cf1 typo
[SVN r31518]
2005-10-31 20:11:23 +00:00
Jaakko Järvi
7f77f987c1 Fixed typos in comments
[SVN r30381]
2005-08-02 17:43:37 +00:00
Jaakko Järvi
d854239945 Patch by Jonathan Wakely to expand special handling of GCC when used in
debug mode.


[SVN r28684]
2005-05-06 05:08:32 +00:00
Jaakko Järvi
4aef261258 added a flag to the test makefile
[SVN r28683]
2005-05-06 05:06:11 +00:00
Jaakko Järvi
6b67606f40 class to struct
[SVN r27493]
2005-02-24 05:27:28 +00:00
Stefan Slapeta
b0ce56c74f replaced BOOST_TEST
[SVN r27057]
2005-02-03 13:55:45 +00:00
Aleksey Gurtovoy
9e45d49139 merge RC_1_32_0 fixes
[SVN r26328]
2004-11-28 03:35:12 +00:00
25 changed files with 511 additions and 562 deletions

12
doc/index.html Normal file
View File

@@ -0,0 +1,12 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=../../../doc/html/lambda.html">
</head>
<body>
Automatic redirection failed, please go to <a href="../../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a>&nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>

View File

@@ -65,7 +65,7 @@ In explaining what the library is about, a line of code says more than a thousan
</para>
</section>
<section id="lambda_sect_getting_started">
<section id="lambda.getting_started">
<title>Getting Started</title>
<section>
@@ -83,41 +83,41 @@ In explaining what the library is about, a line of code says more than a thousan
<listitem><para>
<filename>lambda/lambda.hpp</filename> defines lambda expressions for different C++
operators, see <xref linkend="lambda_sect_operator_expressions"/>.
operators, see <xref linkend="lambda.operator_expressions"/>.
</para></listitem>
<listitem><para>
<filename>lambda/bind.hpp</filename> defines <literal>bind</literal> functions for up to 9 arguments, see <xref linkend="lambda_sect_bind_expressions"/>.</para></listitem>
<filename>lambda/bind.hpp</filename> defines <literal>bind</literal> functions for up to 9 arguments, see <xref linkend="lambda.bind_expressions"/>.</para></listitem>
<listitem><para>
<filename>lambda/if.hpp</filename> defines lambda function equivalents for if statements and the conditional operator, see <xref linkend="lambda_sect_lambda_expressions_for_control_structures"/> (includes <filename>lambda.hpp</filename>).
<filename>lambda/if.hpp</filename> defines lambda function equivalents for if statements and the conditional operator, see <xref linkend="lambda.lambda_expressions_for_control_structures"/> (includes <filename>lambda.hpp</filename>).
</para></listitem>
<listitem><para>
<filename>lambda/loops.hpp</filename> defines lambda function equivalent for looping constructs, see <xref linkend="lambda_sect_lambda_expressions_for_control_structures"/>.
<filename>lambda/loops.hpp</filename> defines lambda function equivalent for looping constructs, see <xref linkend="lambda.lambda_expressions_for_control_structures"/>.
</para></listitem>
<listitem><para>
<filename>lambda/switch.hpp</filename> defines lambda function equivalent for the switch statement, see <xref linkend="lambda_sect_lambda_expressions_for_control_structures"/>.
<filename>lambda/switch.hpp</filename> defines lambda function equivalent for the switch statement, see <xref linkend="lambda.lambda_expressions_for_control_structures"/>.
</para></listitem>
<listitem><para>
<filename>lambda/construct.hpp</filename> provides tools for writing lambda expressions with constructor, destructor, new and delete invocations, see <xref linkend="lambda_sect_construction_and_destruction"/> (includes <filename>lambda.hpp</filename>).
<filename>lambda/construct.hpp</filename> provides tools for writing lambda expressions with constructor, destructor, new and delete invocations, see <xref linkend="lambda.construction_and_destruction"/> (includes <filename>lambda.hpp</filename>).
</para></listitem>
<listitem><para>
<filename>lambda/casts.hpp</filename> provides lambda versions of different casts, as well as <literal>sizeof</literal> and <literal>typeid</literal>, see <xref linkend="lambda_sect_cast_expressions"/>.
<filename>lambda/casts.hpp</filename> provides lambda versions of different casts, as well as <literal>sizeof</literal> and <literal>typeid</literal>, see <xref linkend="lambda.cast_expressions"/>.
</para></listitem>
<listitem><para>
<filename>lambda/exceptions.hpp</filename> gives tools for throwing and catching
exceptions within lambda functions, <xref linkend="lambda_sect_exceptions"/> (includes
exceptions within lambda functions, <xref linkend="lambda.exceptions"/> (includes
<filename>lambda.hpp</filename>).
</para></listitem>
<listitem><para>
<filename>lambda/algorithm.hpp</filename> and <filename>lambda/numeric.hpp</filename> (cf. standard <filename>algortihm</filename> and <filename>numeric</filename> headers) allow nested STL algorithm invocations, see <xref linkend="lambda_sect_nested_stl_algorithms"/>.
<filename>lambda/algorithm.hpp</filename> and <filename>lambda/numeric.hpp</filename> (cf. standard <filename>algortihm</filename> and <filename>numeric</filename> headers) allow nested STL algorithm invocations, see <xref linkend="lambda.nested_stl_algorithms"/>.
</para></listitem>
</itemizedlist>
@@ -165,8 +165,8 @@ The STL contains predefined function objects for some common cases (such as <lit
As an example, one possible implementation for the standard <literal>plus</literal> template is:
<programlisting>
<![CDATA[template <class T> : public binary_function<T, T, T>
struct plus {
<![CDATA[template <class T>
struct plus : public binary_function<T, T, T> {
T operator()(const T& i, const T& j) const {
return i + j;
}
@@ -362,7 +362,7 @@ Hence, there is no syntactic keyword for C++ lambda expressions.
<section id="lambda_sect_partial_function_application">
<section id="lambda.partial_function_application">
<title>Partial function application</title>
<para>
@@ -382,7 +382,7 @@ In partial function application, some of the arguments of a function are bound t
<section id="lambda_sect_terminology">
<section id="lambda.terminology">
<title>Terminology</title>
<para>
@@ -398,7 +398,7 @@ In partial function application, some of the arguments of a function are bound t
</section>
<section id = "lambda_sect_using_library">
<section id = "lambda.using_library">
<title>Using the library</title>
<para>
@@ -408,7 +408,7 @@ There are quite a lot of exceptions and special cases, but discussion of them is
</para>
<section id = "lambda_sect_introductory_examples">
<section id = "lambda.introductory_examples">
<title>Introductory Examples</title>
<para>
@@ -480,7 +480,7 @@ The BLL provides functions <literal>constant</literal> and <literal>var</literal
<programlisting>
<![CDATA[for_each(vp.begin(), vp.end(), cout << constant('\n') << *_1);]]>
</programlisting>
These functions are described more thoroughly in <xref linkend="lambda_sect_delaying_constants_and_variables"/>
These functions are described more thoroughly in <xref linkend="lambda.delaying_constants_and_variables"/>
</para>
@@ -491,7 +491,7 @@ These functions are described more thoroughly in <xref linkend="lambda_sect_dela
</section>
<section id="lambda_sect_parameter_and_return_types">
<section id="lambda.parameter_and_return_types">
<title>Parameter and return types of lambda functors</title>
<para>
@@ -524,8 +524,8 @@ These functions are described more thoroughly in <xref linkend="lambda_sect_dela
<para>
There are two alternative solutions to this.
The first is to extend the BLL type deduction system to cover your own types (see <xref linkend="lambda_sect_extending_return_type_system"/>).
The second is to use a special lambda expression (<literal>ret</literal>) which defines the return type in place (see <xref linkend = "lambda_sect_overriding_deduced_return_type"/>):
The first is to extend the BLL type deduction system to cover your own types (see <xref linkend="lambda.extending"/>).
The second is to use a special lambda expression (<literal>ret</literal>) which defines the return type in place (see <xref linkend = "lambda.overriding_deduced_return_type"/>):
<programlisting><![CDATA[A a; B b; ret<C>(_1 + _2)(a, b);]]></programlisting>
</para>
@@ -536,18 +536,18 @@ These functions are described more thoroughly in <xref linkend="lambda_sect_dela
<!--
A rare case, where the <literal><![CDATA[ret<type>(bind(...))]]></literal> syntax does not work, but
<literal><![CDATA[bind<type>(...)]]></literal> does, is explained in <xref linkend="lambda_sect_nullary_functors_and_ret"/>.
<literal><![CDATA[bind<type>(...)]]></literal> does, is explained in <xref linkend="lambda.nullary_functors_and_ret"/>.
-->
</para>
</section>
<section id="lambda_sect_actual_arguments_to_lambda_functors">
<section id="lambda.actual_arguments_to_lambda_functors">
<title>About actual arguments to lambda functors</title>
<para><emphasis>This section is no longer (or currently) relevant;
<!-- <para><emphasis>This section is no longer (or currently) relevant;
acual arguments can be non-const rvalues.
The section can, however, become relevant again, if in the future BLL will support
lambda functors with higher arities than 3.</emphasis></para>
lambda functors with higher arities than 3.</emphasis></para> -->
<para>A general restriction for the actual arguments is that they cannot be non-const rvalues.
For example:
@@ -562,7 +562,7 @@ int i = 1; int j = 2;
Since the lambda functors are most often called inside STL-algorithms,
the arguments originate from dereferencing iterators and the dereferencing operators seldom return rvalues.
And for the cases where they do, there are workarounds discussed in
<xref linkend="lambda_sect_rvalues_as_actual_arguments"/>.
<xref linkend="lambda.rvalues_as_actual_arguments"/>.
</para>
@@ -570,7 +570,7 @@ int i = 1; int j = 2;
</section>
<section id="lambda_sect_storing_bound_arguments">
<section id="lambda.storing_bound_arguments">
<title>Storing bound arguments in lambda functions</title>
@@ -642,7 +642,7 @@ exist for historical reasons,
and <literal>ref</literal> can always
be replaced with <literal>var</literal>, and <literal>cref</literal> with
<literal>constant_ref</literal>.
See <xref linkend="lambda_sect_delaying_constants_and_variables"/> for details.
See <xref linkend="lambda.delaying_constants_and_variables"/> for details.
The <literal>ref</literal> and <literal>cref</literal> functions are
general purpose utility functions in Boost, and hence defined directly
in the <literal moreinfo="none">boost</literal> namespace.
@@ -702,7 +702,7 @@ This is to prevent pointer arithmetic making non-const arrays const.
</section>
<section id="lambda_sect_lambda_expressions_in_details">
<section id="lambda.le_in_details">
<title>Lambda expressions in details</title>
<para>
@@ -712,7 +712,7 @@ We devote a separate section for each of the possible forms of a lambda expressi
</para>
<section id="lambda_sect_placeholders">
<section id="lambda.placeholders">
<title>Placeholders</title>
<para>
@@ -758,14 +758,14 @@ _1(i, j, k) // returns i, discards j and k
</programlisting>
See
<xref linkend="lambda_sect_why_weak_arity"/> for the design rationale behind this
<xref linkend="lambda.why_weak_arity"/> for the design rationale behind this
functionality.
</para>
<para>
In addition to these three placeholder types, there is also a fourth placeholder type <literal>placeholderE_type</literal>.
The use of this placeholder is defined in <xref linkend="lambda_sect_exceptions"/> describing exception handling in lambda expressions.
The use of this placeholder is defined in <xref linkend="lambda.exceptions"/> describing exception handling in lambda expressions.
</para>
<para>When an actual argument is supplied for a placeholder, the parameter passing mode is always by reference.
@@ -782,7 +782,7 @@ For example:
</section>
<section id="lambda_sect_operator_expressions">
<section id="lambda.operator_expressions">
<title>Operator expressions</title>
<para>
@@ -809,7 +809,7 @@ These operators are <literal>->.</literal>, <literal>-></literal>, <literal>new<
</section>
<section id="lambda_sect_assignment_and_subscript">
<section id="lambda.assignment_and_subscript">
<title>Assignment and subscript operators</title>
<para>
@@ -822,7 +822,7 @@ _1 = i; // ok
i = _1; // not ok. i is not a lambda expression
</programlisting>
There is a simple solution around this limitation, described in <xref linkend="lambda_sect_delaying_constants_and_variables"/>.
There is a simple solution around this limitation, described in <xref linkend="lambda.delaying_constants_and_variables"/>.
In short,
the left hand argument can be explicitly turned into a lambda functor by wrapping it with a special <literal>var</literal> function:
<programlisting>
@@ -832,7 +832,7 @@ var(i) = _1; // ok
</para>
</section>
<section id="lambda_sect_logical_operators">
<section id="lambda.logical_operators">
<title>Logical operators</title>
<para>
@@ -844,7 +844,7 @@ bool flag = true; int i = 0;
</para>
</section>
<section id="lambda_sect_comma_operator">
<section id="lambda.comma_operator">
<title>Comma operator</title>
<para>
@@ -863,7 +863,7 @@ In the above example, each element of <literal>a</literal> is first incremented,
</para>
</section>
<section id="lambda_sect_function_call_operator">
<section id="lambda.function_call_operator">
<title>Function call operator</title>
<para>
@@ -873,7 +873,7 @@ Calls with too few arguments lead to a compile time error.
</para>
</section>
<section id="lambda_sect_member_pointer_operator">
<section id="lambda.member_pointer_operator">
<title>Member pointer operator</title>
<para>
@@ -925,7 +925,7 @@ B* b = new B();
</section>
<section id="lambda_sect_bind_expressions">
<section id="lambda.bind_expressions">
<title>Bind expressions</title>
<para>
@@ -946,7 +946,7 @@ Basically, the
<emphasis><literal>bind-argument-list</literal></emphasis> must be a valid argument list for the target function, except that any argument can be replaced with a placeholder, or more generally, with a lambda expression.
Note that also the target function can be a lambda expression.
The result of a bind expression is either a nullary, unary, binary or 3-ary function object depending on the use of placeholders in the <emphasis><literal>bind-argument-list</literal></emphasis> (see <xref linkend="lambda_sect_placeholders"/>).
The result of a bind expression is either a nullary, unary, binary or 3-ary function object depending on the use of placeholders in the <emphasis><literal>bind-argument-list</literal></emphasis> (see <xref linkend="lambda.placeholders"/>).
</para>
<para>
@@ -961,7 +961,7 @@ This is only necessary if the return type of the target function cannot be deduc
The following sections describe the different types of bind expressions.
</para>
<section id="lambda_sect_function_pointers_as_targets">
<section id="lambda.function_pointers_as_targets">
<title>Function pointers or references as targets</title>
<para>The target function can be a pointer or a reference to a function and it can be either bound or unbound. For example:
@@ -1062,7 +1062,7 @@ find_if(pointers.begin(), pointers.end(), bind(&A::foo, _1, 1));]]>
<para>
Even though the interfaces are the same, there are important semantic differences between using a pointer or a reference as the object argument.
The differences stem from the way <literal>bind</literal>-functions take their parameters, and how the bound parameters are stored within the lambda functor.
The object argument has the same parameter passing and storing mechanism as any other bind argument slot (see <xref linkend="lambda_sect_storing_bound_arguments"/>); it is passed as a const reference and stored as a const copy in the lambda functor.
The object argument has the same parameter passing and storing mechanism as any other bind argument slot (see <xref linkend="lambda.storing_bound_arguments"/>); it is passed as a const reference and stored as a const copy in the lambda functor.
This creates some asymmetry between the lambda functor and the original member function, and between seemingly similar lambda functors. For example:
<programlisting>
class A {
@@ -1114,7 +1114,7 @@ bind(&A::set_j, _1, 1)(a); // a.j == 1]]>
</para>
</section>
<section id="lambda_sect_members_variables_as_targets">
<section id="lambda.members_variables_as_targets">
<title>Member variables as targets</title>
<para>
@@ -1140,7 +1140,7 @@ bind(&A::data, _1)(ca) = 1; // error]]>
</para>
</section>
<section id="lambda_sect_function_objects_as_targets">
<section id="lambda.function_objects_as_targets">
<title>Function objects as targets</title>
<para>
@@ -1235,8 +1235,8 @@ of one of the arguments, and how that dependency can be expressed with the
<![CDATA[struct A {
// the return type equals the third argument type:
template<class T1, T2, T3>
T3 operator()(const T1& t1, const T2& t2, const T3& t3);
template<class T1, class T2, class T3>
T3 operator()(const T1& t1, const T2& t2, const T3& t3) const;
template <class Args>
class sig {
@@ -1246,7 +1246,7 @@ of one of the arguments, and how that dependency can be expressed with the
public:
typedef typename
boost::remove_cv<T3>::type type;
}
};
};]]>
</programlisting>
@@ -1289,12 +1289,12 @@ mechanism first introduced in the FC++ library
</section>
<section id="lambda_sect_overriding_deduced_return_type">
<section id="lambda.overriding_deduced_return_type">
<title>Overriding the deduced return type</title>
<para>
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.
<!-- (see the example in <xref linkend="lambda_sect_parameter_and_return_types"/>).-->
<!-- (see the example in <xref linkend="lambda.parameter_and_return_types"/>).-->
A special lambda expression type is provided for stating the return type explicitly and overriding the deduction system.
To state that the return type of the lambda functor defined by the lambda expression <literal>e</literal> is <literal>T</literal>, you can write:
@@ -1342,10 +1342,10 @@ ret<D>( - ret<C>(_1 + _2))(a, b); // ok]]>
</programlisting>
</para>
<para>If you find yourself using <literal>ret</literal> repeatedly with the same types, it is worth while extending the return type deduction (see <xref linkend="lambda_sect_extending_return_type_system"/>).
<para>If you find yourself using <literal>ret</literal> repeatedly with the same types, it is worth while extending the return type deduction (see <xref linkend="lambda.extending"/>).
</para>
<section id="lambda_sect_nullary_functors_and_ret">
<section id="lambda.nullary_functors_and_ret">
<title>Nullary lambda functors and ret</title>
<para>
@@ -1383,7 +1383,7 @@ apart from the fact that for some nullary lambda functors the former does not wo
</section>
<section id="lambda_sect_delaying_constants_and_variables">
<section id="lambda.delaying_constants_and_variables">
<title>Delaying constants and variables</title>
<para>
@@ -1478,11 +1478,11 @@ for_each(a.begin(),a.end(), cout << space << _1);]]>
<title>About assignment and subscript operators</title>
<para>
As described in <xref linkend="lambda_sect_assignment_and_subscript"/>, assignment and subscripting operators are always defined as member functions.
As described in <xref linkend="lambda.assignment_and_subscript"/>, assignment and subscripting operators are always defined as member functions.
This means, that for expressions of the form
<literal>x = y</literal> or <literal>x[y]</literal> to be interpreted as lambda expressions, the left-hand operand <literal>x</literal> must be a lambda expression.
Consequently, it is sometimes necessary to use <literal>var</literal> for this purpose.
We repeat the example from <xref linkend="lambda_sect_assignment_and_subscript"/>:
We repeat the example from <xref linkend="lambda.assignment_and_subscript"/>:
<programlisting>
int i;
@@ -1501,7 +1501,7 @@ For example, <literal>i += _1</literal> is equivalent to <literal>var(i) += _1</
</section>
<section id="lambda_sect_lambda_expressions_for_control_structures">
<section id="lambda.lambda_expressions_for_control_structures">
<title>Lambda expressions for control structures</title>
<para>
@@ -1561,7 +1561,7 @@ for_each(a, a+5,
</programlisting>
<!--
As explained in <xref linkend="lambda_sect_delaying_constants_and_variables"/>, we can avoid the repeated use of wrapping of <literal>var</literal> if we define it beforehand:
As explained in <xref linkend="lambda.delaying_constants_and_variables"/>, we can avoid the repeated use of wrapping of <literal>var</literal> if we define it beforehand:
<programlisting>
<![CDATA[int i;
@@ -1601,7 +1601,7 @@ of these syntaces.
<section id="lambda_sect_switch_statement">
<section id="lambda.switch_statement">
<title>Switch statement</title>
</section>
@@ -1654,7 +1654,7 @@ Note that another lambda expression is sequenced after the <literal>switch_state
</section>
<section id="lambda_sect_exceptions">
<section id="lambda.exceptions">
<title>Exceptions</title>
<para>
@@ -1734,7 +1734,7 @@ The last line of the second handler constructs a new exception object and
throws that with <literal>throw exception</literal>.
Constructing and destructing objects within lambda expressions is
explained in <xref linkend="lambda_sect_construction_and_destruction"/>
explained in <xref linkend="lambda.construction_and_destruction"/>
</para>
<para>
@@ -1768,7 +1768,7 @@ rethrowing exceptions.
</section>
<section id="lambda_sect_construction_and_destruction">
<section id="lambda.construction_and_destruction">
<title>Construction and destruction</title>
@@ -1940,7 +1940,7 @@ bind(bind(&amp;add_or_mul, _1), _2, _3)(condition, i, j);
<section id="lambda_sect_unlambda">
<section id="lambda.unlambda">
<title>Unlambda</title>
<para>A nested bind expression may occur inadvertently,
@@ -2063,22 +2063,22 @@ and thus finally 13.
<para>
Primary motivation for including <literal>protect</literal> into the library,
was to allow nested STL algorithm invocations
(<xref linkend="lambda_sect_nested_stl_algorithms"/>).
(<xref linkend="lambda.nested_stl_algorithms"/>).
</para>
</section>
</section>
<section id="lambda_sect_rvalues_as_actual_arguments">
<section id="lambda.rvalues_as_actual_arguments">
<title>Rvalues as actual arguments to lambda functors</title>
<para><emphasis>This section and all of its subsections
<!-- <para><emphasis>This section and all of its subsections
are no longer (or currently) relevant;
acual arguments can be non-const rvalues and these workarounds are thus
not needed.
The section can, however, become relevant again, if in the future BLL will support
lambda functors with higher arities than 3.</emphasis></para>
lambda functors with higher arities than 3.</emphasis></para> -->
<para>
Actual arguments to the lambda functors cannot be non-const rvalues.
@@ -2088,7 +2088,7 @@ or there can be no side-effects to the actual arguments.
There are ways around this limitation.
We repeat the example from section
<xref linkend="lambda_sect_actual_arguments_to_lambda_functors"/> and list the
<xref linkend="lambda.actual_arguments_to_lambda_functors"/> and list the
different solutions:
<programlisting>
@@ -2188,7 +2188,7 @@ and are not affected by the non-const rvalue problem.
<section>
<title>Casts, sizeof and typeid</title>
<section id="lambda_sect_cast_expressions">
<section id="lambda.cast_expressions">
<title>
Cast expressions
</title>
@@ -2257,7 +2257,7 @@ function of that class.
</section>
<section id="lambda_sect_nested_stl_algorithms">
<section id="lambda.nested_stl_algorithms">
<title>Nesting STL algorithm invocations</title>
<para>
@@ -2351,11 +2351,11 @@ calling templated functions ...
-->
<section id="lambda_sect_extending_return_type_system">
<section id="lambda.extending">
<title>Extending return type deduction system</title>
<para>
<!--The <xref linkend = "lambda_sect_overriding_deduced_return_type"/> showed how to make BLL aware of the return type of a function object in bind expressions.-->
<!--The <xref linkend = "lambda.overriding_deduced_return_type"/> showed how to make BLL aware of the return type of a function object in bind expressions.-->
In this section, we explain how to extend the return type deduction system
to cover user defined operators.
@@ -2640,6 +2640,7 @@ which require that the argument types are references.
<row><entry><literal><![CDATA[&]]></literal></entry><entry><literal><![CDATA[other_action<address_of_action>]]></literal></entry></row>
<row><entry><literal><![CDATA[*]]></literal></entry><entry><literal><![CDATA[other_action<contents_of_action>]]></literal></entry></row>
<row><entry><literal><![CDATA[,]]></literal></entry><entry><literal><![CDATA[other_action<comma_action>]]></literal></entry></row>
<row><entry><literal><![CDATA[->*]]></literal></entry><entry><literal><![CDATA[other_action<member_pointer_action>]]></literal></entry></row>
</tbody>
</tgroup>
@@ -3147,7 +3148,7 @@ To get this functionality in BLL, the bind expression inside the <literal morein
<programlisting>
bind(unlambda(f), _1)(x);
</programlisting>
as explained in <xref linkend = "lambda_sect_unlambda"/>.
as explained in <xref linkend = "lambda.unlambda"/>.
</section>
@@ -3193,7 +3194,7 @@ to extend the library with new features.
<appendix>
<title>Rationale for some of the design decisions</title>
<section id="lambda_sect_why_weak_arity">
<section id="lambda.why_weak_arity">
<title>
Lambda functor arity
</title>
@@ -3445,16 +3446,7 @@ was dropped.
</biblioentry>
</bibliography>
</library>

0
dummy
View File

View File

@@ -27,7 +27,7 @@ public:
typedef T element_t;
// take all parameters as const rererences. Note that non-const references
// take all parameters as const references. Note that non-const references
// stay as they are.
typedef typename boost::add_reference<
typename boost::add_const<T>::type
@@ -317,7 +317,7 @@ public:
};
// These specializatoins provide a shorter notation to define actions.
// These specializations provide a shorter notation to define actions.
// These lambda_functor_base instances take care of the recursive evaluation
// of the arguments and pass the evaluated arguments to the apply function
// of an action class. To make action X work with these classes, one must

View File

@@ -65,7 +65,7 @@ void do_nothing(A1&, A2&, A3&, A4&) {}
} // lambda
} // boost
// prevent the warnings from unused argumetns
// prevent the warnings from unused arguments
#define CALL_USE_ARGS \
::boost::lambda::detail::do_nothing(a, b, c, env)

View File

@@ -858,9 +858,13 @@ struct return_type_2<other_action<subscript_action>, A, B> {
} // namespace boost
namespace std {
template <class Char, class Traits, class Allocator> class basic_string;
}
// Forward declarations are incompatible with the libstdc++ debug mode.
#if BOOST_WORKAROUND(__GNUC__, >= 3) && defined(_GLIBCXX_DEBUG)
#include <string>
#include <vector>
#include <map>
#include <deque>
#else
// The GCC 2.95.x uses a non-conformant deque
#if BOOST_WORKAROUND(__GNUC__, == 2) && __GNUC_MINOR__ <= 96
@@ -873,12 +877,8 @@ namespace std {
#endif
#if BOOST_WORKAROUND(__GNUC__, == 3) && __GNUC_MINOR__ >=4
#include <vector>
#include <map>
#else
namespace std {
template <class Char, class Traits, class Allocator> class basic_string;
template <class T, class Allocator> class vector;
template <class Key, class T, class Cmp, class Allocator> class map;
template <class Key, class T, class Cmp, class Allocator> class multimap;

View File

@@ -48,7 +48,7 @@ struct try_catch_action {};
struct throw_new_action {};
struct rethrow_action {};
template<class ThrowType> class throw_action;
template<class ThrowType> struct throw_action;
template<>
struct throw_action<rethrow_action> {

View File

@@ -3,6 +3,10 @@
<meta http-equiv="refresh" content="0; URL=../../doc/html/lambda.html">
</head>
<body>
Automatic redirection failed, please go to <a href="../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a>
Automatic redirection failed, please go to <a href="../../doc/html/lambda.html">www.boost.org/doc/html/lambda.html</a>&nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>

View File

@@ -1,59 +0,0 @@
# Lambda library
# Copyright (C) 2001-2003 Jaakko Järvi
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# For more information, see http://www.boost.org/
subproject libs/lambda/test ;
# bring in rules for testing
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
include testing.jam ;
# Make tests run by default.
DEPENDS all : test ;
{
# look in BOOST_ROOT for sources first, just in this Jamfile
local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ;
test-suite lambda
:
[ run libs/lambda/test/algorithm_test.cpp : : : : ]
[ run libs/lambda/test/bind_tests_simple.cpp : : : : ]
[ run libs/lambda/test/bind_tests_advanced.cpp : : : : ]
[ run libs/lambda/test/bind_tests_simple_f_refs.cpp : : : : ]
[ run libs/lambda/test/bll_and_function.cpp : : : : ]
[ run libs/lambda/test/cast_test.cpp : : : : ]
[ run libs/lambda/test/constructor_tests.cpp : : : : ]
[ run libs/lambda/test/control_structures.cpp : : : : ]
[ run libs/lambda/test/exception_test.cpp : : : : ]
[ run libs/lambda/test/extending_rt_traits.cpp : : : : ]
[ run libs/lambda/test/is_instance_of_test.cpp : : : : ]
[ run libs/lambda/test/member_pointer_test.cpp : : : : ]
[ run libs/lambda/test/operator_tests_simple.cpp : : : : ]
[ run libs/lambda/test/phoenix_control_structures.cpp : : : : ]
[ run libs/lambda/test/switch_construct.cpp : : : : ]
;
}

View File

@@ -1,7 +1,7 @@
BOOST = ../../..
CXX = gcc
EXTRAFLAGS = -pedantic -Wno-long-long -ftemplate-depth-50
CXX = g++
EXTRAFLAGS = -pedantic -Wno-long-long -Wno-long-double -ftemplate-depth-50
LIBS = -lstdc++
#CXX = KCC

View File

@@ -41,7 +41,7 @@ void test_foreach() {
bind(ll::for_each(), _1, _1 + 20,
protect((sum += _1))));
BOOST_TEST(sum == (199 + 1)/ 2 * 199);
BOOST_CHECK(sum == (199 + 1)/ 2 * 199);
}
// More tests needed (for all algorithms)

View File

@@ -60,16 +60,16 @@ void test_nested_binds()
bool condition;
condition = true;
BOOST_TEST(bind(bind(&sum_or_product, _1), 1, 2)(condition)==3);
BOOST_TEST(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==5);
BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==3);
BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==5);
condition = false;
BOOST_TEST(bind(bind(&sum_or_product, _1), 1, 2)(condition)==2);
BOOST_TEST(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==6);
BOOST_CHECK(bind(bind(&sum_or_product, _1), 1, 2)(condition)==2);
BOOST_CHECK(bind(bind(&sum_or_product, _1), _2, _3)(condition, j, k)==6);
which_one wo;
BOOST_TEST(bind(bind(bind(wo), _1), _2, _3)(condition, j, k)==6);
BOOST_CHECK(bind(bind(bind(wo), _1), _2, _3)(condition, j, k)==6);
return;
@@ -109,14 +109,14 @@ void test_unlambda() {
int i = 1;
BOOST_TEST(unlambda(_1 + _2)(i, i) == 2);
BOOST_TEST(unlambda(++var(i))() == 2);
BOOST_TEST(call_with_100(_1 + 1) == 101);
BOOST_CHECK(unlambda(_1 + _2)(i, i) == 2);
BOOST_CHECK(unlambda(++var(i))() == 2);
BOOST_CHECK(call_with_100(_1 + 1) == 101);
BOOST_TEST(call_with_101(_1 + 1) == 102);
BOOST_CHECK(call_with_101(_1 + 1) == 102);
BOOST_TEST(call_with_100(bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
BOOST_CHECK(call_with_100(bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
// std_functor insturcts LL that the functor defines a result_type typedef
// rather than a sig template.
@@ -200,7 +200,7 @@ void test_protect()
bind(ll::for_each(), _1, _1 + 5,
protect(sum += _1))
);
BOOST_TEST(sum == (1+15)*15/2);
BOOST_CHECK(sum == (1+15)*15/2);
sum = 0;
@@ -208,17 +208,17 @@ void test_protect()
bind(ll::for_each(), _1, _1 + 5,
sum += 1 + protect(_1)) // add element count
);
BOOST_TEST(sum == (1+15)*15/2 + 15);
BOOST_CHECK(sum == (1+15)*15/2 + 15);
(1 + protect(_1))(sum);
int k = 0;
((k += constant(1)) += protect(constant(2)))();
BOOST_TEST(k==1);
BOOST_CHECK(k==1);
k = 0;
((k += constant(1)) += protect(constant(2)))()();
BOOST_TEST(k==3);
BOOST_CHECK(k==3);
// note, the following doesn't work:
@@ -276,10 +276,10 @@ void test_lambda_functors_as_arguments_to_lambda_functors() {
// sum_0() + 7, but rather
// bind(sum_0) + 7, which results in another lambda functor
// (lambda functor + int) and can be called again
BOOST_TEST((_1 + _2)(bind(&sum_0), make_const(7))() == 7);
BOOST_CHECK((_1 + _2)(bind(&sum_0), make_const(7))() == 7);
int i = 3, j = 12;
BOOST_TEST((_1 - _2)(_2, _1)(i, j) == j - i);
BOOST_CHECK((_1 - _2)(_2, _1)(i, j) == j - i);
// also, note that lambda functor are no special case for bind if received
// as a parameter. In oder to be bindable, the functor must
@@ -292,12 +292,12 @@ void test_lambda_functors_as_arguments_to_lambda_functors() {
int a = 5, b = 6;
// Let type deduction find out the return type
BOOST_TEST(bind(_1, _2, _3)(unlambda(_1 + _2), a, b) == 11);
BOOST_CHECK(bind(_1, _2, _3)(unlambda(_1 + _2), a, b) == 11);
//specify it yourself:
BOOST_TEST(bind(_1, _2, _3)(ret<int>(_1 + _2), a, b) == 11);
BOOST_TEST(ret<int>(bind(_1, _2, _3))(_1 + _2, a, b) == 11);
BOOST_TEST(bind<int>(_1, _2, _3)(_1 + _2, a, b) == 11);
BOOST_CHECK(bind(_1, _2, _3)(ret<int>(_1 + _2), a, b) == 11);
BOOST_CHECK(ret<int>(bind(_1, _2, _3))(_1 + _2, a, b) == 11);
BOOST_CHECK(bind<int>(_1, _2, _3)(_1 + _2, a, b) == 11);
bind(_1,1.0)(_1+_1);
return;
@@ -310,10 +310,10 @@ void test_const_parameters() {
// (_1 + _2)(1, 2); // this would fail,
// Either make arguments const:
BOOST_TEST((_1 + _2)(make_const(1), make_const(2)) == 3);
BOOST_CHECK((_1 + _2)(make_const(1), make_const(2)) == 3);
// Or use const_parameters:
BOOST_TEST(const_parameters(_1 + _2)(1, 2) == 3);
BOOST_CHECK(const_parameters(_1 + _2)(1, 2) == 3);
@@ -323,7 +323,7 @@ void test_rvalue_arguments()
{
// Not quite working yet.
// Problems with visual 7.1
// BOOST_TEST((_1 + _2)(1, 2) == 3);
// BOOST_CHECK((_1 + _2)(1, 2) == 3);
}
void test_break_const()
@@ -348,7 +348,7 @@ void test_break_const()
// OLD COMMENT: (_1 += _2)(i, 2) // fails, 2 is a non-const rvalue
// OLD COMMENT: const_parameters(_1 += _2)(i, 2) // fails, side-effect to i
break_const(_1 += _2)(i, 2); // ok
BOOST_TEST(i == 3);
BOOST_CHECK(i == 3);
}
int test_main(int, char *[]) {

View File

@@ -65,18 +65,18 @@ void test_member_functions()
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11);
BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11);
BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11);
BOOST_TEST(bind(&A::add2, _1, 1, 1)(a) == 12);
BOOST_TEST(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
BOOST_TEST(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
BOOST_TEST(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
BOOST_TEST(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
BOOST_TEST(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
BOOST_TEST(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
BOOST_CHECK(bind(&A::add2, _1, 1, 1)(a) == 12);
BOOST_CHECK(bind(&A::add3, _1, 1, 1, 1)(a) == 13);
BOOST_CHECK(bind(&A::add4, _1, 1, 1, 1, 1)(a) == 14);
BOOST_CHECK(bind(&A::add5, _1, 1, 1, 1, 1, 1)(a) == 15);
BOOST_CHECK(bind(&A::add6, _1, 1, 1, 1, 1, 1, 1)(a) == 16);
BOOST_CHECK(bind(&A::add7, _1, 1, 1, 1, 1, 1, 1, 1)(a) == 17);
BOOST_CHECK(bind(&A::add8, _1, 1, 1, 1, 1, 1, 1, 1, 1)(a) == 18);
// This should fail, as lambda functors store arguments as const
// bind(&A::add, a, _1);
@@ -88,56 +88,56 @@ int test_main(int, char *[]) {
int result;
// bind all parameters
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, 1)()==1);
BOOST_TEST(bind(&sum_of_args_2, 1, 2)()==3);
BOOST_TEST(bind(&sum_of_args_3, 1, 2, 3)()==6);
BOOST_TEST(bind(&sum_of_args_4, 1, 2, 3, 4)()==10);
BOOST_TEST(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15);
BOOST_TEST(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
BOOST_TEST(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
BOOST_TEST(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
BOOST_TEST(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
BOOST_CHECK(bind(&sum_of_args_0)()==0);
BOOST_CHECK(bind(&sum_of_args_1, 1)()==1);
BOOST_CHECK(bind(&sum_of_args_2, 1, 2)()==3);
BOOST_CHECK(bind(&sum_of_args_3, 1, 2, 3)()==6);
BOOST_CHECK(bind(&sum_of_args_4, 1, 2, 3, 4)()==10);
BOOST_CHECK(bind(&sum_of_args_5, 1, 2, 3, 4, 5)()==15);
BOOST_CHECK(bind(&sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
BOOST_CHECK(bind(&sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
BOOST_CHECK(bind(&sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
BOOST_CHECK(bind(&sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
// first parameter open
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, 2)(i)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, 2, 3)(i)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
BOOST_CHECK(bind(&sum_of_args_0)()==0);
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(&sum_of_args_2, _1, 2)(i)==3);
BOOST_CHECK(bind(&sum_of_args_3, _1, 2, 3)(i)==6);
BOOST_CHECK(bind(&sum_of_args_4, _1, 2, 3, 4)(i)==10);
BOOST_CHECK(bind(&sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
BOOST_CHECK(bind(&sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
BOOST_CHECK(bind(&sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
BOOST_CHECK(bind(&sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
BOOST_CHECK(bind(&sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
// two open arguments
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
BOOST_CHECK(bind(&sum_of_args_0)()==0);
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_CHECK(bind(&sum_of_args_3, _1, _2, 3)(i, j)==6);
BOOST_CHECK(bind(&sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
BOOST_CHECK(bind(&sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
BOOST_CHECK(bind(&sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
BOOST_CHECK(bind(&sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
BOOST_CHECK(bind(&sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
BOOST_CHECK(bind(&sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
// three open arguments
BOOST_TEST(bind(&sum_of_args_0)()==0);
BOOST_TEST(bind(&sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6);
BOOST_TEST(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
BOOST_TEST(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
BOOST_TEST(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
BOOST_TEST(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
BOOST_TEST(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
BOOST_TEST(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
BOOST_CHECK(bind(&sum_of_args_0)()==0);
BOOST_CHECK(bind(&sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(&sum_of_args_2, _1, _2)(i, j)==3);
BOOST_CHECK(bind(&sum_of_args_3, _1, _2, _3)(i, j, k)==6);
BOOST_CHECK(bind(&sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
BOOST_CHECK(bind(&sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
BOOST_CHECK(bind(&sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
BOOST_CHECK(bind(&sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
BOOST_CHECK(bind(&sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
BOOST_CHECK(bind(&sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
// function compositions with bind
BOOST_TEST(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8);
BOOST_TEST(
BOOST_CHECK(bind(&sum_of_args_3, bind(&sum_of_args_2, _1, 2), 2, 3)(i)==8);
BOOST_CHECK(
bind(&sum_of_args_9,
bind(&sum_of_args_0), // 0
bind(&sum_of_args_1, _1), // 1
@@ -163,7 +163,7 @@ int test_main(int, char *[]) {
_3,
4)
)(i, j, k);
BOOST_TEST(result == 12);
BOOST_CHECK(result == 12);
test_member_functions();

View File

@@ -50,10 +50,10 @@ void test_member_functions()
A a(10);
int i = 1;
BOOST_TEST(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_TEST(bind(&A::add, &a, _1)(i) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(a) == 11);
BOOST_TEST(bind(&A::add, _1, 1)(make_const(&a)) == 11);
BOOST_CHECK(bind(&A::add, ref(a), _1)(i) == 11);
BOOST_CHECK(bind(&A::add, &a, _1)(i) == 11);
BOOST_CHECK(bind(&A::add, _1, 1)(a) == 11);
BOOST_CHECK(bind(&A::add, _1, 1)(make_const(&a)) == 11);
// This should fail, as lambda functors store arguments as const
// bind(&A::add, a, _1);
@@ -66,56 +66,56 @@ int test_main(int, char *[]) {
// bind all parameters
BOOST_TEST(bind(sum_of_args_0)()==0);
BOOST_TEST(bind(sum_of_args_1, 1)()==1);
BOOST_TEST(bind(sum_of_args_2, 1, 2)()==3);
BOOST_TEST(bind(sum_of_args_3, 1, 2, 3)()==6);
BOOST_TEST(bind(sum_of_args_4, 1, 2, 3, 4)()==10);
BOOST_TEST(bind(sum_of_args_5, 1, 2, 3, 4, 5)()==15);
BOOST_TEST(bind(sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
BOOST_TEST(bind(sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
BOOST_TEST(bind(sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
BOOST_TEST(bind(sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
BOOST_CHECK(bind(sum_of_args_0)()==0);
BOOST_CHECK(bind(sum_of_args_1, 1)()==1);
BOOST_CHECK(bind(sum_of_args_2, 1, 2)()==3);
BOOST_CHECK(bind(sum_of_args_3, 1, 2, 3)()==6);
BOOST_CHECK(bind(sum_of_args_4, 1, 2, 3, 4)()==10);
BOOST_CHECK(bind(sum_of_args_5, 1, 2, 3, 4, 5)()==15);
BOOST_CHECK(bind(sum_of_args_6, 1, 2, 3, 4, 5, 6)()==21);
BOOST_CHECK(bind(sum_of_args_7, 1, 2, 3, 4, 5, 6, 7)()==28);
BOOST_CHECK(bind(sum_of_args_8, 1, 2, 3, 4, 5, 6, 7, 8)()==36);
BOOST_CHECK(bind(sum_of_args_9, 1, 2, 3, 4, 5, 6, 7, 8, 9)()==45);
// first parameter open
BOOST_TEST(bind(sum_of_args_0)()==0);
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(sum_of_args_2, _1, 2)(i)==3);
BOOST_TEST(bind(sum_of_args_3, _1, 2, 3)(i)==6);
BOOST_TEST(bind(sum_of_args_4, _1, 2, 3, 4)(i)==10);
BOOST_TEST(bind(sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
BOOST_TEST(bind(sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
BOOST_TEST(bind(sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
BOOST_TEST(bind(sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
BOOST_TEST(bind(sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
BOOST_CHECK(bind(sum_of_args_0)()==0);
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(sum_of_args_2, _1, 2)(i)==3);
BOOST_CHECK(bind(sum_of_args_3, _1, 2, 3)(i)==6);
BOOST_CHECK(bind(sum_of_args_4, _1, 2, 3, 4)(i)==10);
BOOST_CHECK(bind(sum_of_args_5, _1, 2, 3, 4, 5)(i)==15);
BOOST_CHECK(bind(sum_of_args_6, _1, 2, 3, 4, 5, 6)(i)==21);
BOOST_CHECK(bind(sum_of_args_7, _1, 2, 3, 4, 5, 6, 7)(i)==28);
BOOST_CHECK(bind(sum_of_args_8, _1, 2, 3, 4, 5, 6, 7, 8)(i)==36);
BOOST_CHECK(bind(sum_of_args_9, _1, 2, 3, 4, 5, 6, 7, 8, 9)(i)==45);
// two open arguments
BOOST_TEST(bind(sum_of_args_0)()==0);
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(sum_of_args_3, _1, _2, 3)(i, j)==6);
BOOST_TEST(bind(sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
BOOST_TEST(bind(sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
BOOST_TEST(bind(sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
BOOST_TEST(bind(sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
BOOST_TEST(bind(sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
BOOST_TEST(bind(sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
BOOST_CHECK(bind(sum_of_args_0)()==0);
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3);
BOOST_CHECK(bind(sum_of_args_3, _1, _2, 3)(i, j)==6);
BOOST_CHECK(bind(sum_of_args_4, _1, _2, 3, 4)(i, j)==10);
BOOST_CHECK(bind(sum_of_args_5, _1, _2, 3, 4, 5)(i, j)==15);
BOOST_CHECK(bind(sum_of_args_6, _1, _2, 3, 4, 5, 6)(i, j)==21);
BOOST_CHECK(bind(sum_of_args_7, _1, _2, 3, 4, 5, 6, 7)(i, j)==28);
BOOST_CHECK(bind(sum_of_args_8, _1, _2, 3, 4, 5, 6, 7, 8)(i, j)==36);
BOOST_CHECK(bind(sum_of_args_9, _1, _2, 3, 4, 5, 6, 7, 8, 9)(i, j)==45);
// three open arguments
BOOST_TEST(bind(sum_of_args_0)()==0);
BOOST_TEST(bind(sum_of_args_1, _1)(i)==1);
BOOST_TEST(bind(sum_of_args_2, _1, _2)(i, j)==3);
BOOST_TEST(bind(sum_of_args_3, _1, _2, _3)(i, j, k)==6);
BOOST_TEST(bind(sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
BOOST_TEST(bind(sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
BOOST_TEST(bind(sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
BOOST_TEST(bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
BOOST_TEST(bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
BOOST_TEST(bind(sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
BOOST_CHECK(bind(sum_of_args_0)()==0);
BOOST_CHECK(bind(sum_of_args_1, _1)(i)==1);
BOOST_CHECK(bind(sum_of_args_2, _1, _2)(i, j)==3);
BOOST_CHECK(bind(sum_of_args_3, _1, _2, _3)(i, j, k)==6);
BOOST_CHECK(bind(sum_of_args_4, _1, _2, _3, 4)(i, j, k)==10);
BOOST_CHECK(bind(sum_of_args_5, _1, _2, _3, 4, 5)(i, j, k)==15);
BOOST_CHECK(bind(sum_of_args_6, _1, _2, _3, 4, 5, 6)(i, j, k)==21);
BOOST_CHECK(bind(sum_of_args_7, _1, _2, _3, 4, 5, 6, 7)(i, j, k)==28);
BOOST_CHECK(bind(sum_of_args_8, _1, _2, _3, 4, 5, 6, 7, 8)(i, j, k)==36);
BOOST_CHECK(bind(sum_of_args_9, _1, _2, _3, 4, 5, 6, 7, 8, 9)(i, j, k)==45);
// function compositions with bind
BOOST_TEST(bind(sum_of_args_3, bind(sum_of_args_2, _1, 2), 2, 3)(i)==8);
BOOST_TEST(
BOOST_CHECK(bind(sum_of_args_3, bind(sum_of_args_2, _1, 2), 2, 3)(i)==8);
BOOST_CHECK(
bind(sum_of_args_9,
bind(sum_of_args_0), // 0
bind(sum_of_args_1, _1), // 1
@@ -141,7 +141,7 @@ int test_main(int, char *[]) {
_3,
4)
)(i, j, k);
BOOST_TEST(result == 12);
BOOST_CHECK(result == 12);
test_member_functions();

View File

@@ -32,12 +32,12 @@ void test_function() {
boost::function<int (int, int)> f;
f = _1 + _2;
BOOST_TEST(f(1, 2)== 3);
BOOST_CHECK(f(1, 2)== 3);
int i=1; int j=2;
boost::function<int& (int&, int)> g = _1 += _2;
g(i, j);
BOOST_TEST(i==3);
BOOST_CHECK(i==3);
@@ -45,7 +45,7 @@ void test_function() {
*sum = 0;
boost::function<int& (int)> counter = *sum += _1;
counter(5); // ok, sum* = 5;
BOOST_TEST(*sum == 5);
BOOST_CHECK(*sum == 5);
delete sum;
// The next statement would lead to a dangling reference

View File

@@ -53,46 +53,46 @@ void do_test() {
(var(b) = ll_static_cast<base *>(p_derived))();
(var(d) = ll_static_cast<derived *>(b))();
BOOST_TEST(b->class_name() == "derived");
BOOST_TEST(d->class_name() == "derived");
BOOST_CHECK(b->class_name() == "derived");
BOOST_CHECK(d->class_name() == "derived");
(var(b) = ll_dynamic_cast<derived *>(b))();
BOOST_TEST(b != 0);
BOOST_TEST(b->class_name() == "derived");
BOOST_CHECK(b != 0);
BOOST_CHECK(b->class_name() == "derived");
(var(d) = ll_dynamic_cast<derived *>(p_base))();
BOOST_TEST(d == 0);
BOOST_CHECK(d == 0);
const derived* p_const_derived = p_derived;
BOOST_TEST(p_const_derived->class_name() == "const derived");
BOOST_CHECK(p_const_derived->class_name() == "const derived");
(var(d) = ll_const_cast<derived *>(p_const_derived))();
BOOST_TEST(d->class_name() == "derived");
BOOST_CHECK(d->class_name() == "derived");
int i = 10;
char* cp = reinterpret_cast<char*>(&i);
int* ip;
(var(ip) = ll_reinterpret_cast<int *>(cp))();
BOOST_TEST(*ip == 10);
BOOST_CHECK(*ip == 10);
// typeid
BOOST_TEST(string(ll_typeid(d)().name()) == string(typeid(d).name()));
BOOST_CHECK(string(ll_typeid(d)().name()) == string(typeid(d).name()));
// sizeof
BOOST_TEST(ll_sizeof(_1)(p_derived) == sizeof(p_derived));
BOOST_TEST(ll_sizeof(_1)(*p_derived) == sizeof(*p_derived));
BOOST_TEST(ll_sizeof(_1)(p_base) == sizeof(p_base));
BOOST_TEST(ll_sizeof(_1)(*p_base) == sizeof(*p_base));
BOOST_CHECK(ll_sizeof(_1)(p_derived) == sizeof(p_derived));
BOOST_CHECK(ll_sizeof(_1)(*p_derived) == sizeof(*p_derived));
BOOST_CHECK(ll_sizeof(_1)(p_base) == sizeof(p_base));
BOOST_CHECK(ll_sizeof(_1)(*p_base) == sizeof(*p_base));
int an_array[100];
BOOST_TEST(ll_sizeof(_1)(an_array) == 100 * sizeof(int));
BOOST_CHECK(ll_sizeof(_1)(an_array) == 100 * sizeof(int));
delete p_derived;
delete p_base;

View File

@@ -45,63 +45,63 @@ void constructor_all_lengths()
bind(constructor<tuple<int> >(),
1)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int> >(),
1, 2)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int> >(),
1, 2, 3)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int> >(),
1, 2, 3, 4)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int, int> >(),
1, 2, 3, 4, 5)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7, 8)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
bind(constructor<tuple<int, int, int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7, 8, 9)()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
}
@@ -113,63 +113,63 @@ void new_ptr_all_lengths()
*(bind(new_ptr<tuple<int> >(),
1))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int> >(),
1, 2))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int> >(),
1, 2, 3))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int> >(),
1, 2, 3, 4))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int, int> >(),
1, 2, 3, 4, 5))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7, 8))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
ok = check_tuple(
1,
*(bind(new_ptr<tuple<int, int, int, int, int, int, int, int, int> >(),
1, 2, 3, 4, 5, 6, 7, 8, 9))()
);
BOOST_TEST(ok);
BOOST_CHECK(ok);
}
@@ -186,14 +186,14 @@ void test_destructor ()
bool flag;
is_destructor_called* idc = new(space) is_destructor_called(flag);
BOOST_TEST(flag == false);
BOOST_CHECK(flag == false);
bind(destructor(), _1)(idc);
BOOST_TEST(flag == true);
BOOST_CHECK(flag == true);
idc = new(space) is_destructor_called(flag);
BOOST_TEST(flag == false);
BOOST_CHECK(flag == false);
bind(destructor(), _1)(*idc);
BOOST_TEST(flag == true);
BOOST_CHECK(flag == true);
}
@@ -212,14 +212,14 @@ void test_news_and_deletes ()
int count_errors = 0;
for_each(i, i+10, (*_1 == 2) || ++var(count_errors));
BOOST_TEST(count_errors == 0);
BOOST_CHECK(count_errors == 0);
count_deletes* ct[10];
for_each(ct, ct+10, _1 = bind(new_ptr<count_deletes>()));
count_deletes::count = 0;
for_each(ct, ct+10, bind(delete_ptr(), _1));
BOOST_TEST(count_deletes::count == 10);
BOOST_CHECK(count_deletes::count == 10);
}
@@ -230,7 +230,7 @@ void test_array_new_and_delete()
count_deletes::count = 0;
bind(delete_array(), _1)(c);
BOOST_TEST(count_deletes::count == 5);
BOOST_CHECK(count_deletes::count == 5);
}

View File

@@ -50,41 +50,41 @@ void simple_loops() {
int i;
int arithmetic_series = 0;
for_loop(_1 = 0, _1 < 10, _1++, arithmetic_series += _1)(i);
BOOST_TEST(arithmetic_series == 45);
BOOST_CHECK(arithmetic_series == 45);
// no body case
for_loop(boost::lambda::var(i) = 0, boost::lambda::var(i) < 100, ++boost::lambda::var(i))();
BOOST_TEST(i == 100);
BOOST_CHECK(i == 100);
// while loops -------------------------------------------------------
int a = 0, b = 0, c = 0;
while_loop((_1 + _2) >= (_1 * _2), (++_1, ++_2, ++_3))(a, b, c);
BOOST_TEST(c == 3);
BOOST_CHECK(c == 3);
int count;
count = 0; i = 0;
while_loop(_1++ < 10, ++boost::lambda::var(count))(i);
BOOST_TEST(count == 10);
BOOST_CHECK(count == 10);
// note that the first parameter of do_while_loop is the condition
count = 0; i = 0;
do_while_loop(_1++ < 10, ++boost::lambda::var(count))(i);
BOOST_TEST(count == 11);
BOOST_CHECK(count == 11);
a = 0;
do_while_loop(constant(false), _1++)(a);
BOOST_TEST(a == 1);
BOOST_CHECK(a == 1);
// no body cases
a = 40; b = 30;
while_loop(--_1 > _2)(a, b);
BOOST_TEST(a == b);
BOOST_CHECK(a == b);
// (the no body case for do_while_loop is pretty redundant)
a = 40; b = 30;
do_while_loop(--_1 > _2)(a, b);
BOOST_TEST(a == b);
BOOST_CHECK(a == b);
}
@@ -93,25 +93,25 @@ void simple_ifs () {
int value = 42;
if_then(_1 < 0, _1 = 0)(value);
BOOST_TEST(value == 42);
BOOST_CHECK(value == 42);
value = -42;
if_then(_1 < 0, _1 = -_1)(value);
BOOST_TEST(value == 42);
BOOST_CHECK(value == 42);
int min;
if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2)
(make_const(1), make_const(2));
BOOST_TEST(min == 1);
BOOST_CHECK(min == 1);
if_then_else(_1 < _2, boost::lambda::var(min) = _1, boost::lambda::var(min) = _2)
(make_const(5), make_const(3));
BOOST_TEST(min == 3);
BOOST_CHECK(min == 3);
int x, y;
x = -1; y = 1;
BOOST_TEST(if_then_else_return(_1 < _2, _2, _1)(x, y) == (std::max)(x ,y));
BOOST_TEST(if_then_else_return(_1 < _2, _2, _1)(y, x) == (std::max)(x ,y));
BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(x, y) == (std::max)(x ,y));
BOOST_CHECK(if_then_else_return(_1 < _2, _2, _1)(y, x) == (std::max)(x ,y));
}

View File

@@ -98,7 +98,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 1);
BOOST_CHECK(ecount == 1);
ecount = 0;
for(int i=1; i<=2; i++)
@@ -113,7 +113,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 2);
BOOST_CHECK(ecount == 2);
ecount = 0;
for(int i=1; i<=3; i++)
@@ -131,7 +131,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 3);
BOOST_CHECK(ecount == 3);
ecount = 0;
for(int i=1; i<=4; i++)
@@ -152,7 +152,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 4);
BOOST_CHECK(ecount == 4);
ecount = 0;
for(int i=1; i<=5; i++)
@@ -176,7 +176,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 5);
BOOST_CHECK(ecount == 5);
ecount = 0;
for(int i=1; i<=6; i++)
@@ -203,7 +203,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 6);
BOOST_CHECK(ecount == 6);
ecount = 0;
for(int i=1; i<=7; i++)
@@ -233,7 +233,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 7);
BOOST_CHECK(ecount == 7);
ecount = 0;
for(int i=1; i<=8; i++)
@@ -266,7 +266,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 8);
BOOST_CHECK(ecount == 8);
ecount = 0;
for(int i=1; i<=9; i++)
@@ -302,7 +302,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 9);
BOOST_CHECK(ecount == 9);
// with catch(...) blocks
@@ -317,7 +317,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 1);
BOOST_CHECK(ecount == 1);
ecount = 0;
for(int i=1; i<=2; i++)
@@ -332,7 +332,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 2);
BOOST_CHECK(ecount == 2);
ecount = 0;
for(int i=1; i<=3; i++)
@@ -350,7 +350,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 3);
BOOST_CHECK(ecount == 3);
ecount = 0;
for(int i=1; i<=4; i++)
@@ -371,7 +371,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 4);
BOOST_CHECK(ecount == 4);
ecount = 0;
for(int i=1; i<=5; i++)
@@ -395,7 +395,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 5);
BOOST_CHECK(ecount == 5);
ecount = 0;
for(int i=1; i<=6; i++)
@@ -422,7 +422,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 6);
BOOST_CHECK(ecount == 6);
ecount = 0;
for(int i=1; i<=7; i++)
@@ -452,7 +452,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 7);
BOOST_CHECK(ecount == 7);
ecount = 0;
for(int i=1; i<=8; i++)
@@ -485,7 +485,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 8);
BOOST_CHECK(ecount == 8);
ecount = 0;
for(int i=1; i<=9; i++)
@@ -521,7 +521,7 @@ void test_different_number_of_catch_blocks() {
)
)(i);
}
BOOST_TEST(ecount == 9);
BOOST_CHECK(ecount == 9);
}
void test_empty_catch_blocks() {
@@ -551,7 +551,7 @@ void return_type_matching() {
int i = 1;
BOOST_TEST(
BOOST_CHECK(
try_catch(
_1 + 1,
@@ -575,14 +575,14 @@ void return_type_matching() {
make_void(_1 += 1),
catch_exception<char>(_e) // since try is void, catch can return anything
)(i);
BOOST_TEST(i == 2);
BOOST_CHECK(i == 2);
try_catch(
(_1 += 1, throw_exception('a')),
catch_exception<char>(_e) // since try throws, it is void,
// so catch can return anything
)(i);
BOOST_TEST(i == 3);
BOOST_CHECK(i == 3);
char a = 'a';
try_catch(
@@ -592,7 +592,7 @@ void return_type_matching() {
),
catch_exception<char>( _1 = _e )
)(a);
BOOST_TEST(a == 'b');
BOOST_CHECK(a == 'b');
}
int test_main(int, char *[]) {
@@ -605,11 +605,11 @@ int test_main(int, char *[]) {
}
catch (int x)
{
BOOST_TEST(false);
BOOST_CHECK(false);
}
catch(...)
{
BOOST_TEST(false);
BOOST_CHECK(false);
}

View File

@@ -96,7 +96,7 @@ void test_unary_operators()
ok((&_1)(a));
ok((*_1)(a));
BOOST_TEST((*_1)(make_const(&i)) == 1);
BOOST_CHECK((*_1)(make_const(&i)) == 1);
}
class X {};

View File

@@ -53,25 +53,25 @@ using boost::lambda::is_instance_of_3;
using boost::lambda::is_instance_of_4;
BOOST_TEST((is_instance_of_1<B1, A1>::value == true));
BOOST_TEST((is_instance_of_1<A1<float>, A1>::value == true));
BOOST_TEST((is_instance_of_1<int, A1>::value == false));
BOOST_TEST((is_instance_of_1<C1, A1>::value == false));
BOOST_CHECK((is_instance_of_1<B1, A1>::value == true));
BOOST_CHECK((is_instance_of_1<A1<float>, A1>::value == true));
BOOST_CHECK((is_instance_of_1<int, A1>::value == false));
BOOST_CHECK((is_instance_of_1<C1, A1>::value == false));
BOOST_TEST((is_instance_of_2<B2, A2>::value == true));
BOOST_TEST((is_instance_of_2<A2<int, float>, A2>::value == true));
BOOST_TEST((is_instance_of_2<int, A2>::value == false));
BOOST_TEST((is_instance_of_2<C2, A2>::value == false));
BOOST_CHECK((is_instance_of_2<B2, A2>::value == true));
BOOST_CHECK((is_instance_of_2<A2<int, float>, A2>::value == true));
BOOST_CHECK((is_instance_of_2<int, A2>::value == false));
BOOST_CHECK((is_instance_of_2<C2, A2>::value == false));
BOOST_TEST((is_instance_of_3<B3, A3>::value == true));
BOOST_TEST((is_instance_of_3<A3<int, float, char>, A3>::value == true));
BOOST_TEST((is_instance_of_3<int, A3>::value == false));
BOOST_TEST((is_instance_of_3<C3, A3>::value == false));
BOOST_CHECK((is_instance_of_3<B3, A3>::value == true));
BOOST_CHECK((is_instance_of_3<A3<int, float, char>, A3>::value == true));
BOOST_CHECK((is_instance_of_3<int, A3>::value == false));
BOOST_CHECK((is_instance_of_3<C3, A3>::value == false));
BOOST_TEST((is_instance_of_4<B4, A4>::value == true));
BOOST_TEST((is_instance_of_4<A4<int, float, char, double>, A4>::value == true));
BOOST_TEST((is_instance_of_4<int, A4>::value == false));
BOOST_TEST((is_instance_of_4<C4, A4>::value == false));
BOOST_CHECK((is_instance_of_4<B4, A4>::value == true));
BOOST_CHECK((is_instance_of_4<A4<int, float, char, double>, A4>::value == true));
BOOST_CHECK((is_instance_of_4<int, A4>::value == false));
BOOST_CHECK((is_instance_of_4<C4, A4>::value == false));
return 0;

View File

@@ -50,65 +50,65 @@ void pointer_to_data_member_tests() {
// int i = 0;
my_struct *y = &x;
BOOST_TEST((_1 ->* &my_struct::mem)(y) == 3);
BOOST_CHECK((_1 ->* &my_struct::mem)(y) == 3);
(_1 ->* &my_struct::mem)(y) = 4;
BOOST_TEST(x.mem == 4);
BOOST_CHECK(x.mem == 4);
((_1 ->* &my_struct::mem) = 5)(y);
BOOST_TEST(x.mem == 5);
BOOST_CHECK(x.mem == 5);
// &my_struct::mem is a temporary, must be constified
((y ->* _1) = 6)(make_const(&my_struct::mem));
BOOST_TEST(x.mem == 6);
BOOST_CHECK(x.mem == 6);
((_1 ->* _2) = 7)(y, make_const(&my_struct::mem));
BOOST_TEST(x.mem == 7);
BOOST_CHECK(x.mem == 7);
}
void pointer_to_member_function_tests() {
my_struct *y = new my_struct(1);
BOOST_TEST( (_1 ->* &my_struct::foo)(y)() == (y->mem));
BOOST_TEST( (_1 ->* &my_struct::fooc)(y)() == (y->mem));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo))() == (y->mem));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::fooc))() == (y->mem));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo))() == (y->mem));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::fooc))() == (y->mem));
BOOST_CHECK( (_1 ->* &my_struct::foo)(y)() == (y->mem));
BOOST_CHECK( (_1 ->* &my_struct::fooc)(y)() == (y->mem));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo))() == (y->mem));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::fooc))() == (y->mem));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo))() == (y->mem));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::fooc))() == (y->mem));
BOOST_TEST( (_1 ->* &my_struct::foo1)(y)(1) == (y->mem+1));
BOOST_TEST( (_1 ->* &my_struct::foo1c)(y)(1) == (y->mem+1));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo1))(1) == (y->mem+1));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo1c))(1) == (y->mem+1));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo1))(1) == (y->mem+1));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo1c))(1) == (y->mem+1));
BOOST_CHECK( (_1 ->* &my_struct::foo1)(y)(1) == (y->mem+1));
BOOST_CHECK( (_1 ->* &my_struct::foo1c)(y)(1) == (y->mem+1));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1))(1) == (y->mem+1));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo1c))(1) == (y->mem+1));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1))(1) == (y->mem+1));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo1c))(1) == (y->mem+1));
BOOST_TEST( (_1 ->* &my_struct::foo2)(y)(1,2) == (y->mem+1+2));
BOOST_TEST( (_1 ->* &my_struct::foo2c)(y)(1,2) == (y->mem+1+2));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
BOOST_CHECK( (_1 ->* &my_struct::foo2)(y)(1,2) == (y->mem+1+2));
BOOST_CHECK( (_1 ->* &my_struct::foo2c)(y)(1,2) == (y->mem+1+2));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2))(1,2) == (y->mem+1+2));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo2c))(1,2) == (y->mem+1+2));
BOOST_TEST( (_1 ->* &my_struct::foo3)(y)(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (_1 ->* &my_struct::foo3c)(y)(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (_1 ->* &my_struct::foo3)(y)(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (_1 ->* &my_struct::foo3c)(y)(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3))(1,2,3) == (y->mem+1+2+3));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo3c))(1,2,3) == (y->mem+1+2+3));
BOOST_TEST( (_1 ->* &my_struct::foo4)(y)(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_TEST( (_1 ->* &my_struct::foo4c)(y)(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_TEST( (y ->* _1)(make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_TEST( (_1 ->* _2)(y, make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (_1 ->* &my_struct::foo4)(y)(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (_1 ->* &my_struct::foo4c)(y)(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (y ->* _1)(make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4))(1,2,3,4) == (y->mem+1+2+3+4));
BOOST_CHECK( (_1 ->* _2)(y, make_const(&my_struct::foo4c))(1,2,3,4) == (y->mem+1+2+3+4));
// member functions with default values do not work (inherent language issue)
// BOOST_TEST( (_1 ->* &my_struct::foo3default)(y)() == (y->mem+1+2+3));
// BOOST_CHECK( (_1 ->* &my_struct::foo3default)(y)() == (y->mem+1+2+3));
}
@@ -163,21 +163,21 @@ void test_overloaded_pointer_to_member()
A a; B b;
// this won't work, can't deduce the return type
// BOOST_TEST((_1->*_2)(a, b) == false);
// BOOST_CHECK((_1->*_2)(a, b) == false);
// ret<bool> gives the return type
BOOST_TEST(ret<bool>(_1->*_2)(a, b) == false);
BOOST_TEST(ret<bool>(a->*_1)(b) == false);
BOOST_TEST(ret<bool>(_1->*b)(a) == false);
BOOST_TEST((ret<bool>((var(a))->*b))() == false);
BOOST_TEST((ret<bool>((var(a))->*var(b)))() == false);
BOOST_CHECK(ret<bool>(_1->*_2)(a, b) == false);
BOOST_CHECK(ret<bool>(a->*_1)(b) == false);
BOOST_CHECK(ret<bool>(_1->*b)(a) == false);
BOOST_CHECK((ret<bool>((var(a))->*b))() == false);
BOOST_CHECK((ret<bool>((var(a))->*var(b)))() == false);
// this is ok without ret<bool> due to the return_type_2 spcialization above
BOOST_TEST((_1->*_2)(b, a) == true);
BOOST_TEST((b->*_1)(a) == true);
BOOST_TEST((_1->*a)(b) == true);
BOOST_TEST((var(b)->*a)() == true);
BOOST_CHECK((_1->*_2)(b, a) == true);
BOOST_CHECK((b->*_1)(a) == true);
BOOST_CHECK((_1->*a)(b) == true);
BOOST_CHECK((var(b)->*a)() == true);
return;
}

View File

@@ -47,7 +47,7 @@ void cout_tests()
(os << constant("FOO"))();
BOOST_TEST(os.str() == std::string("10FOO"));
BOOST_CHECK(os.str() == std::string("10FOO"));
istringstream is("ABC 1");
@@ -57,21 +57,21 @@ void cout_tests()
is >> s;
is >> k;
BOOST_TEST(s == std::string("ABC"));
BOOST_TEST(k == 1);
BOOST_CHECK(s == std::string("ABC"));
BOOST_CHECK(k == 1);
// test for constant, constant_ref and var
i = 5;
constant_type<int>::type ci(constant(i));
var_type<int>::type vi(var(i));
(vi = _1)(make_const(100));
BOOST_TEST((ci)() == 5);
BOOST_TEST(i == 100);
BOOST_CHECK((ci)() == 5);
BOOST_CHECK(i == 100);
int a;
constant_ref_type<int>::type cr(constant_ref(i));
(++vi, var(a) = cr)();
BOOST_TEST(i == 101);
BOOST_CHECK(i == 101);
#endif
}
@@ -81,17 +81,17 @@ void arithmetic_operators() {
using namespace std;
using namespace boost::lambda;
BOOST_TEST((_1 + 1)(i)==2);
BOOST_TEST(((_1 + 1) * _2)(i, j)==4);
BOOST_TEST((_1 - 1)(i)==0);
BOOST_CHECK((_1 + 1)(i)==2);
BOOST_CHECK(((_1 + 1) * _2)(i, j)==4);
BOOST_CHECK((_1 - 1)(i)==0);
BOOST_TEST((_1 * 2)(j)==4);
BOOST_TEST((_1 / 2)(j)==1);
BOOST_CHECK((_1 * 2)(j)==4);
BOOST_CHECK((_1 / 2)(j)==1);
BOOST_TEST((_1 % 2)(k)==1);
BOOST_CHECK((_1 % 2)(k)==1);
BOOST_TEST((-_1)(i) == -1);
BOOST_TEST((+_1)(i) == 1);
BOOST_CHECK((-_1)(i) == -1);
BOOST_CHECK((+_1)(i) == 1);
// test that unary plus really does something
unary_plus_tester u;
@@ -101,95 +101,95 @@ void arithmetic_operators() {
void bitwise_operators() {
unsigned int ui = 2;
BOOST_TEST((_1 << 1)(ui)==(2 << 1));
BOOST_TEST((_1 >> 1)(ui)==(2 >> 1));
BOOST_CHECK((_1 << 1)(ui)==(2 << 1));
BOOST_CHECK((_1 >> 1)(ui)==(2 >> 1));
BOOST_TEST((_1 & 1)(ui)==(2 & 1));
BOOST_TEST((_1 | 1)(ui)==(2 | 1));
BOOST_TEST((_1 ^ 1)(ui)==(2 ^ 1));
BOOST_TEST((~_1)(ui)==~2u);
BOOST_CHECK((_1 & 1)(ui)==(2 & 1));
BOOST_CHECK((_1 | 1)(ui)==(2 | 1));
BOOST_CHECK((_1 ^ 1)(ui)==(2 ^ 1));
BOOST_CHECK((~_1)(ui)==~2u);
}
void comparison_operators() {
int i = 0, j = 1;
BOOST_TEST((_1 < _2)(i, j) == true);
BOOST_TEST((_1 <= _2)(i, j) == true);
BOOST_TEST((_1 == _2)(i, j) == false);
BOOST_TEST((_1 != _2)(i, j) == true);
BOOST_TEST((_1 > _2)(i, j) == false);
BOOST_TEST((_1 >= _2)(i, j) == false);
BOOST_CHECK((_1 < _2)(i, j) == true);
BOOST_CHECK((_1 <= _2)(i, j) == true);
BOOST_CHECK((_1 == _2)(i, j) == false);
BOOST_CHECK((_1 != _2)(i, j) == true);
BOOST_CHECK((_1 > _2)(i, j) == false);
BOOST_CHECK((_1 >= _2)(i, j) == false);
BOOST_TEST((!(_1 < _2))(i, j) == false);
BOOST_TEST((!(_1 <= _2))(i, j) == false);
BOOST_TEST((!(_1 == _2))(i, j) == true);
BOOST_TEST((!(_1 != _2))(i, j) == false);
BOOST_TEST((!(_1 > _2))(i, j) == true);
BOOST_TEST((!(_1 >= _2))(i, j) == true);
BOOST_CHECK((!(_1 < _2))(i, j) == false);
BOOST_CHECK((!(_1 <= _2))(i, j) == false);
BOOST_CHECK((!(_1 == _2))(i, j) == true);
BOOST_CHECK((!(_1 != _2))(i, j) == false);
BOOST_CHECK((!(_1 > _2))(i, j) == true);
BOOST_CHECK((!(_1 >= _2))(i, j) == true);
}
void logical_operators() {
bool t = true, f = false;
BOOST_TEST((_1 && _2)(t, t) == true);
BOOST_TEST((_1 && _2)(t, f) == false);
BOOST_TEST((_1 && _2)(f, t) == false);
BOOST_TEST((_1 && _2)(f, f) == false);
BOOST_CHECK((_1 && _2)(t, t) == true);
BOOST_CHECK((_1 && _2)(t, f) == false);
BOOST_CHECK((_1 && _2)(f, t) == false);
BOOST_CHECK((_1 && _2)(f, f) == false);
BOOST_TEST((_1 || _2)(t, t) == true);
BOOST_TEST((_1 || _2)(t, f) == true);
BOOST_TEST((_1 || _2)(f, t) == true);
BOOST_TEST((_1 || _2)(f, f) == false);
BOOST_CHECK((_1 || _2)(t, t) == true);
BOOST_CHECK((_1 || _2)(t, f) == true);
BOOST_CHECK((_1 || _2)(f, t) == true);
BOOST_CHECK((_1 || _2)(f, f) == false);
BOOST_TEST((!_1)(t) == false);
BOOST_TEST((!_1)(f) == true);
BOOST_CHECK((!_1)(t) == false);
BOOST_CHECK((!_1)(f) == true);
// test short circuiting
int i=0;
(false && ++_1)(i);
BOOST_TEST(i==0);
BOOST_CHECK(i==0);
i = 0;
(true && ++_1)(i);
BOOST_TEST(i==1);
BOOST_CHECK(i==1);
i = 0;
(false || ++_1)(i);
BOOST_TEST(i==1);
BOOST_CHECK(i==1);
i = 0;
(true || ++_1)(i);
BOOST_TEST(i==0);
BOOST_CHECK(i==0);
i = 0;
}
void unary_incs_and_decs() {
int i = 0;
BOOST_TEST(_1++(i) == 0);
BOOST_TEST(i == 1);
BOOST_CHECK(_1++(i) == 0);
BOOST_CHECK(i == 1);
i = 0;
BOOST_TEST(_1--(i) == 0);
BOOST_TEST(i == -1);
BOOST_CHECK(_1--(i) == 0);
BOOST_CHECK(i == -1);
i = 0;
BOOST_TEST((++_1)(i) == 1);
BOOST_TEST(i == 1);
BOOST_CHECK((++_1)(i) == 1);
BOOST_CHECK(i == 1);
i = 0;
BOOST_TEST((--_1)(i) == -1);
BOOST_TEST(i == -1);
BOOST_CHECK((--_1)(i) == -1);
BOOST_CHECK(i == -1);
i = 0;
// the result of prefix -- and ++ are lvalues
(++_1)(i) = 10;
BOOST_TEST(i==10);
BOOST_CHECK(i==10);
i = 0;
(--_1)(i) = 10;
BOOST_TEST(i==10);
BOOST_CHECK(i==10);
i = 0;
}
@@ -199,77 +199,77 @@ void compound_operators() {
// normal variable as the left operand
(i += _1)(make_const(1));
BOOST_TEST(i == 2);
BOOST_CHECK(i == 2);
(i -= _1)(make_const(1));
BOOST_TEST(i == 1);
BOOST_CHECK(i == 1);
(i *= _1)(make_const(10));
BOOST_TEST(i == 10);
BOOST_CHECK(i == 10);
(i /= _1)(make_const(2));
BOOST_TEST(i == 5);
BOOST_CHECK(i == 5);
(i %= _1)(make_const(2));
BOOST_TEST(i == 1);
BOOST_CHECK(i == 1);
// lambda expression as a left operand
(_1 += 1)(i);
BOOST_TEST(i == 2);
BOOST_CHECK(i == 2);
(_1 -= 1)(i);
BOOST_TEST(i == 1);
BOOST_CHECK(i == 1);
(_1 *= 10)(i);
BOOST_TEST(i == 10);
BOOST_CHECK(i == 10);
(_1 /= 2)(i);
BOOST_TEST(i == 5);
BOOST_CHECK(i == 5);
(_1 %= 2)(i);
BOOST_TEST(i == 1);
BOOST_CHECK(i == 1);
// shifts
unsigned int ui = 2;
(_1 <<= 1)(ui);
BOOST_TEST(ui==(2 << 1));
BOOST_CHECK(ui==(2 << 1));
ui = 2;
(_1 >>= 1)(ui);
BOOST_TEST(ui==(2 >> 1));
BOOST_CHECK(ui==(2 >> 1));
ui = 2;
(ui <<= _1)(make_const(1));
BOOST_TEST(ui==(2 << 1));
BOOST_CHECK(ui==(2 << 1));
ui = 2;
(ui >>= _1)(make_const(1));
BOOST_TEST(ui==(2 >> 1));
BOOST_CHECK(ui==(2 >> 1));
// and, or, xor
ui = 2;
(_1 &= 1)(ui);
BOOST_TEST(ui==(2 & 1));
BOOST_CHECK(ui==(2 & 1));
ui = 2;
(_1 |= 1)(ui);
BOOST_TEST(ui==(2 | 1));
BOOST_CHECK(ui==(2 | 1));
ui = 2;
(_1 ^= 1)(ui);
BOOST_TEST(ui==(2 ^ 1));
BOOST_CHECK(ui==(2 ^ 1));
ui = 2;
(ui &= _1)(make_const(1));
BOOST_TEST(ui==(2 & 1));
BOOST_CHECK(ui==(2 & 1));
ui = 2;
(ui |= _1)(make_const(1));
BOOST_TEST(ui==(2 | 1));
BOOST_CHECK(ui==(2 | 1));
ui = 2;
(ui ^= _1)(make_const(1));
BOOST_TEST(ui==(2 ^ 1));
BOOST_CHECK(ui==(2 ^ 1));
}
@@ -283,24 +283,24 @@ void assignment_and_subscript() {
string s;
(_1 = "one")(s);
BOOST_TEST(s == string("one"));
BOOST_CHECK(s == string("one"));
(var(s) = "two")();
BOOST_TEST(s == string("two"));
BOOST_CHECK(s == string("two"));
BOOST_TEST((var(s)[_1])(make_const(2)) == 'o');
BOOST_TEST((_1[2])(s) == 'o');
BOOST_TEST((_1[_2])(s, make_const(2)) == 'o');
BOOST_CHECK((var(s)[_1])(make_const(2)) == 'o');
BOOST_CHECK((_1[2])(s) == 'o');
BOOST_CHECK((_1[_2])(s, make_const(2)) == 'o');
// subscript returns lvalue
(var(s)[_1])(make_const(1)) = 'o';
BOOST_TEST(s == "too");
BOOST_CHECK(s == "too");
(_1[1])(s) = 'a';
BOOST_TEST(s == "tao");
BOOST_CHECK(s == "tao");
(_1[_2])(s, make_const(0)) = 'm';
BOOST_TEST(s == "mao");
BOOST_CHECK(s == "mao");
// TODO: tests for vector, set, map, multimap
}
@@ -311,14 +311,14 @@ void address_of_and_dereference() {
A a; int i = 42;
BOOST_TEST((&_1)(a) == &a);
BOOST_TEST((*&_1)(i) == 42);
BOOST_CHECK((&_1)(a) == &a);
BOOST_CHECK((*&_1)(i) == 42);
std::vector<int> vi; vi.push_back(1);
std::vector<int>::iterator it = vi.begin();
(*_1 = 7)(it);
BOOST_TEST(vi[0] == 7);
BOOST_CHECK(vi[0] == 7);
// TODO: Add tests for more complex iterator types
}
@@ -328,7 +328,7 @@ void address_of_and_dereference() {
void comma() {
int i = 100;
BOOST_TEST((_1 = 10, 2 * _1)(i) == 20);
BOOST_CHECK((_1 = 10, 2 * _1)(i) == 20);
// TODO: that the return type is the exact type of the right argument
// (that r/l valueness is preserved)
@@ -347,32 +347,32 @@ void pointer_arithmetic() {
// non-const array
BOOST_TEST((*(_1 + 1))(ia) == 2);
BOOST_CHECK((*(_1 + 1))(ia) == 2);
// non-const pointer
BOOST_TEST((*(_1 + 1))(ip) == 2);
BOOST_CHECK((*(_1 + 1))(ip) == 2);
BOOST_TEST((*(_1 - 1))(ia_last) == 3);
BOOST_CHECK((*(_1 - 1))(ia_last) == 3);
// const array
BOOST_TEST((*(_1 + 1))(cia) == 2);
BOOST_CHECK((*(_1 + 1))(cia) == 2);
// const pointer
BOOST_TEST((*(_1 + 1))(cip) == 2);
BOOST_TEST((*(_1 - 1))(cia_last) == 3);
BOOST_CHECK((*(_1 + 1))(cip) == 2);
BOOST_CHECK((*(_1 - 1))(cia_last) == 3);
// pointer arithmetic should not make non-consts const
(*(_1 + 2))(ia) = 0;
(*(_1 + 3))(ip) = 0;
BOOST_TEST(ia[2] == 0);
BOOST_TEST(ia[3] == 0);
BOOST_CHECK(ia[2] == 0);
BOOST_CHECK(ia[3] == 0);
// pointer - pointer
BOOST_TEST((_1 - _2)(ia_last, ia) == 3);
BOOST_TEST((_1 - _2)(cia_last, cia) == 3);
BOOST_TEST((ia_last - _1)(ia) == 3);
BOOST_TEST((cia_last - _1)(cia) == 3);
BOOST_TEST((cia_last - _1)(cip) == 3);
BOOST_CHECK((_1 - _2)(ia_last, ia) == 3);
BOOST_CHECK((_1 - _2)(cia_last, cia) == 3);
BOOST_CHECK((ia_last - _1)(ia) == 3);
BOOST_CHECK((cia_last - _1)(cia) == 3);
BOOST_CHECK((cia_last - _1)(cip) == 3);
}

View File

@@ -60,7 +60,7 @@ int test_main(int, char *[]) {
]
);
BOOST_TEST(sum == 4+5+6+7+8);
BOOST_CHECK(sum == 4+5+6+7+8);
int gt = 0, eq = 0, lt = 0;
//////////////////////////////////
@@ -82,9 +82,9 @@ int test_main(int, char *[]) {
]
);
BOOST_TEST(lt==4);
BOOST_TEST(eq==1);
BOOST_TEST(gt==5);
BOOST_CHECK(lt==4);
BOOST_CHECK(eq==1);
BOOST_CHECK(gt==5);
vector<int> t = v;
@@ -101,8 +101,8 @@ int test_main(int, char *[]) {
)
);
BOOST_TEST(counta == 55);
BOOST_TEST(countb == 10);
BOOST_CHECK(counta == 55);
BOOST_CHECK(countb == 10);
v = t;
@@ -120,8 +120,8 @@ int test_main(int, char *[]) {
)
);
BOOST_TEST(counta == (2+11)*10/2);
BOOST_TEST(countb == 10);
BOOST_CHECK(counta == (2+11)*10/2);
BOOST_CHECK(countb == 10);
v = t;
@@ -138,8 +138,8 @@ int test_main(int, char *[]) {
)
);
BOOST_TEST(counta == (1+10)*10/2);
BOOST_TEST(countb == 10);
BOOST_CHECK(counta == (1+10)*10/2);
BOOST_CHECK(countb == 10);
v = t;

View File

@@ -63,7 +63,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 0));
BOOST_CHECK(check(w, 0));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -75,7 +75,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 1));
BOOST_CHECK(check(w, 1));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -88,7 +88,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 2));
BOOST_CHECK(check(w, 2));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -102,7 +102,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 3));
BOOST_CHECK(check(w, 3));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -117,7 +117,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 4));
BOOST_CHECK(check(w, 4));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -133,7 +133,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 5));
BOOST_CHECK(check(w, 5));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -150,7 +150,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 6));
BOOST_CHECK(check(w, 6));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -168,7 +168,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 7));
BOOST_CHECK(check(w, 7));
std::fill_n(w.begin(), 10, 0);
// ---
@@ -187,7 +187,7 @@ void do_switch_no_defaults_tests() {
)
);
BOOST_TEST(check(w, 8));
BOOST_CHECK(check(w, 8));
std::fill_n(w.begin(), 10, 0);
}
@@ -216,8 +216,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, -1));
BOOST_TEST(default_count == 10);
BOOST_CHECK(check(w, -1));
BOOST_CHECK(default_count == 10);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -230,8 +230,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 0));
BOOST_TEST(default_count == 9);
BOOST_CHECK(check(w, 0));
BOOST_CHECK(default_count == 9);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -245,8 +245,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 1));
BOOST_TEST(default_count == 8);
BOOST_CHECK(check(w, 1));
BOOST_CHECK(default_count == 8);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -261,8 +261,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 2));
BOOST_TEST(default_count == 7);
BOOST_CHECK(check(w, 2));
BOOST_CHECK(default_count == 7);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -278,8 +278,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 3));
BOOST_TEST(default_count == 6);
BOOST_CHECK(check(w, 3));
BOOST_CHECK(default_count == 6);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -296,8 +296,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 4));
BOOST_TEST(default_count == 5);
BOOST_CHECK(check(w, 4));
BOOST_CHECK(default_count == 5);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -315,8 +315,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 5));
BOOST_TEST(default_count == 4);
BOOST_CHECK(check(w, 5));
BOOST_CHECK(default_count == 4);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -335,8 +335,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 6));
BOOST_TEST(default_count == 3);
BOOST_CHECK(check(w, 6));
BOOST_CHECK(default_count == 3);
std::fill_n(w.begin(), 10, 0);
// ---
@@ -356,8 +356,8 @@ void do_switch_yes_defaults_tests() {
)
);
BOOST_TEST(check(w, 7));
BOOST_TEST(default_count == 2);
BOOST_CHECK(check(w, 7));
BOOST_CHECK(default_count == 2);
std::fill_n(w.begin(), 10, 0);
}