2
0
mirror of https://github.com/boostorg/lambda.git synced 2026-01-23 17:42:52 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Ronald Garcia
18f471fc40 Created a branch from trunk
[SVN r38959]
2007-08-26 05:34:35 +00:00
56 changed files with 842 additions and 1056 deletions

View File

@@ -1,21 +1,5 @@
project lambda/doc ; project boost/doc ;
import boostbook : boostbook ; import boostbook : boostbook ;
# Are these really the correct images?? boostbook lambda-doc : lambda.xml ;
path-constant images : ../../spirit/phoenix/doc/html ;
boostbook lambda-doc : lambda.xml
:
<xsl:param>boost.root=../../../..
<format>pdf:<xsl:param>img.src.path=$(images)/
;
###############################################################################
alias boostdoc
: lambda.xml
:
:
: ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;

View File

@@ -3435,7 +3435,7 @@ was dropped.
<firstname>Brian</firstname> <firstname>Brian</firstname>
<surname>McNamara</surname> <surname>McNamara</surname>
</author> </author>
<bibliomisc><ulink url="http://yanniss.github.io/fc++/">yanniss.github.io/fc++/ </ulink> <bibliomisc><ulink url="http://www.cc.gatech.edu/~yannis/fc++/">www.cc.gatech.edu/~yannis/fc++/</ulink>
</bibliomisc> </bibliomisc>
<pubdate>2002</pubdate> <pubdate>2002</pubdate>
</biblioentry> </biblioentry>

View File

@@ -44,7 +44,7 @@
<para> <para>
The Boost Lambda Library (BLL in the sequel) is a C++ template The Boost Lambda Library (BLL in the sequel) is a C++ template
library, which implements a form of <emphasis>lambda abstractions</emphasis> for C++. library, which implements form of <emphasis>lambda abstractions</emphasis> for C++.
The term originates from functional programming and lambda calculus, where a lambda abstraction defines an unnamed function. The term originates from functional programming and lambda calculus, where a lambda abstraction defines an unnamed function.
The primary motivation for the BLL is to provide flexible and The primary motivation for the BLL is to provide flexible and
convenient means to define unnamed function objects for STL algorithms. convenient means to define unnamed function objects for STL algorithms.
@@ -1908,7 +1908,7 @@ For example:
int foo(int); int bar(int); int foo(int); int bar(int);
... ...
int i; int i;
bind(foo, bind(bar, _1))(i); bind(foo, bind(bar, _1)(i);
</programlisting> </programlisting>
The last line makes the call <literal>foo(bar(i));</literal> The last line makes the call <literal>foo(bar(i));</literal>
@@ -3191,7 +3191,7 @@ to extend the library with new features.
<section> <appendix>
<title>Rationale for some of the design decisions</title> <title>Rationale for some of the design decisions</title>
<section id="lambda.why_weak_arity"> <section id="lambda.why_weak_arity">
@@ -3256,7 +3256,7 @@ was dropped.
</section> </section>
</section> </appendix>
@@ -3440,7 +3440,7 @@ was dropped.
<firstname>Brian</firstname> <firstname>Brian</firstname>
<surname>McNamara</surname> <surname>McNamara</surname>
</author> </author>
<bibliomisc><ulink url="http://yanniss.github.io/fc++/">yanniss.github.io/fc++/ </ulink> <bibliomisc><ulink url="http://www.cc.gatech.edu/~yannis/fc++/">www.cc.gatech.edu/~yannis/fc++/</ulink>
</bibliomisc> </bibliomisc>
<pubdate>2002</pubdate> <pubdate>2002</pubdate>
</biblioentry> </biblioentry>

View File

@@ -1,5 +1,5 @@
// -- algorithm.hpp -- Boost Lambda Library ----------------------------------- // -- algorithm.hpp -- Boost Lambda Library -----------------------------------
// Copyright (C) 2002 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2002 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com) // Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,6 +1,6 @@
// -- bind.hpp -- Boost Lambda Library -------------------------------------- // -- bind.hpp -- Boost Lambda Library --------------------------------------
// Copyright (C) 1999-2001 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999-2001 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Gary Powell (gwpowell@hotmail.com) // Gary Powell (gwpowell@hotmail.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,7 +1,7 @@
// - casts.hpp -- BLambda Library ------------- // - casts.hpp -- BLambda Library -------------
// //
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -14,17 +14,11 @@
#if !defined(BOOST_LAMBDA_CASTS_HPP) #if !defined(BOOST_LAMBDA_CASTS_HPP)
#define BOOST_LAMBDA_CASTS_HPP #define BOOST_LAMBDA_CASTS_HPP
#include "boost/lambda/detail/suppress_unused.hpp"
#include "boost/lambda/core.hpp"
#include <typeinfo> #include <typeinfo>
namespace boost { namespace boost {
namespace lambda { namespace lambda {
template<class Act, class Args>
struct return_type_N;
template<class T> class cast_action; template<class T> class cast_action;
template<class T> class static_cast_action; template<class T> class static_cast_action;
@@ -70,12 +64,11 @@ public:
} }
}; };
// typeid action // typedid action
class typeid_action { class typeid_action {
public: public:
template<class RET, class Arg1> template<class RET, class Arg1>
static RET apply(Arg1 &a1) { static RET apply(Arg1 &a1) {
detail::suppress_unused_variable_warnings(a1);
return typeid(a1); return typeid(a1);
} }
}; };

View File

@@ -251,7 +251,7 @@ private:
closure& operator=(closure const&); // no assign closure& operator=(closure const&); // no assign
template <int N, typename ClosureT> template <int N, typename ClosureT>
friend class closure_member; friend struct closure_member;
template <typename ClosureT> template <typename ClosureT>
friend class closure_frame; friend class closure_frame;

View File

@@ -1,7 +1,7 @@
// - construct.hpp -- Lambda Library ------------- // - construct.hpp -- Lambda Library -------------
// //
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -14,9 +14,6 @@
#if !defined(BOOST_LAMBDA_CONSTRUCT_HPP) #if !defined(BOOST_LAMBDA_CONSTRUCT_HPP)
#define BOOST_LAMBDA_CONSTRUCT_HPP #define BOOST_LAMBDA_CONSTRUCT_HPP
#include "boost/type_traits/remove_cv.hpp"
#include "boost/type_traits/is_pointer.hpp"
namespace boost { namespace boost {
namespace lambda { namespace lambda {

View File

@@ -1,5 +1,5 @@
// -- control_structures.hpp -- Boost Lambda Library -------------------------- // -- control_structures.hpp -- Boost Lambda Library --------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,6 @@
#include "boost/lambda/detail/operator_actions.hpp" #include "boost/lambda/detail/operator_actions.hpp"
#include "boost/lambda/detail/operator_return_type_traits.hpp" #include "boost/lambda/detail/operator_return_type_traits.hpp"
#include "boost/lambda/if.hpp" #include "boost/lambda/detail/control_structures_impl.hpp"
#include "boost/lambda/loops.hpp"
#endif #endif

View File

@@ -1,7 +1,7 @@
// -- core.hpp -- Boost Lambda Library ------------------------------------- // -- core.hpp -- Boost Lambda Library -------------------------------------
// //
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// -- Boost Lambda Library - actions.hpp ---------------------------------- // -- Boost Lambda Library - actions.hpp ----------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// -- Boost Lambda Library ------------------------------------------------- // -- Boost Lambda Library -------------------------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// -- bind_functions.hpp -- Boost Lambda Library // -- bind_functions.hpp -- Boost Lambda Library
// //
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library -- control_constructs_common.hpp ------------------- // Boost Lambda Library -- control_constructs_common.hpp -------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -0,0 +1,550 @@
// Boost Lambda Library -- control_structures_impl.hpp ---------------------
// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000 Gary Powell (powellg@amazon.com)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
// --------------------------------------------------------------------------
#if !defined(BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP)
#define BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP
namespace boost {
namespace lambda {
// -- void return control actions ----------------------
class forloop_action {};
class forloop_no_body_action {};
class ifthen_action {};
class ifthenelse_action {};
class whileloop_action {};
class whileloop_no_body_action {};
class dowhileloop_action {};
class dowhileloop_no_body_action {};
// -- nonvoid return control actions ----------------------
class ifthenelsereturn_action {};
// For loop
template <class Arg1, class Arg2, class Arg3, class Arg4>
inline const
lambda_functor<
lambda_functor_base<
forloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >
>
>
for_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3, const lambda_functor<Arg4>& a4) {
return
lambda_functor_base<
forloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3>, lambda_functor<Arg4> >(a1, a2, a3, a4)
);
}
// No body case.
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
forloop_no_body_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
>
for_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3) {
return
lambda_functor_base<
forloop_no_body_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2>,
lambda_functor<Arg3> >(a1, a2, a3) );
}
// While loop
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
whileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
while_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
whileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2));
}
// No body case.
template <class Arg1>
inline const
lambda_functor<
lambda_functor_base<
whileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
>
while_loop(const lambda_functor<Arg1>& a1) {
return
lambda_functor_base<
whileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
( tuple<lambda_functor<Arg1> >(a1) );
}
// Do While loop
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
dowhileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
do_while_loop(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
dowhileloop_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2));
}
// No body case.
template <class Arg1>
inline const
lambda_functor<
lambda_functor_base<
dowhileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
>
do_while_loop(const lambda_functor<Arg1>& a1) {
return
lambda_functor_base<
dowhileloop_no_body_action,
tuple<lambda_functor<Arg1> >
>
( tuple<lambda_functor<Arg1> >(a1));
}
// If Then
template <class Arg1, class Arg2>
inline const
lambda_functor<
lambda_functor_base<
ifthen_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
>
if_then(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2) {
return
lambda_functor_base<
ifthen_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >
>
( tuple<lambda_functor<Arg1>, lambda_functor<Arg2> >(a1, a2) );
}
// If then else
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
ifthenelse_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
>
if_then_else(const lambda_functor<Arg1>& a1, const lambda_functor<Arg2>& a2,
const lambda_functor<Arg3>& a3) {
return
lambda_functor_base<
ifthenelse_action,
tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
>
(tuple<lambda_functor<Arg1>, lambda_functor<Arg2>, lambda_functor<Arg3> >
(a1, a2, a3) );
}
// Our version of operator?:()
template <class Arg1, class Arg2, class Arg3>
inline const
lambda_functor<
lambda_functor_base<
other_action<ifthenelsereturn_action>,
tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type>
>
>
if_then_else_return(const lambda_functor<Arg1>& a1,
const Arg2 & a2,
const Arg3 & a3) {
return
lambda_functor_base<
other_action<ifthenelsereturn_action>,
tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type>
> ( tuple<lambda_functor<Arg1>,
typename const_copy_argument<Arg2>::type,
typename const_copy_argument<Arg3>::type> (a1, a2, a3) );
}
namespace detail {
// return type specialization for conditional expression begins -----------
// start reading below and move upwards
// PHASE 6:1
// check if A is conbertible to B and B to A
template<int Phase, bool AtoB, bool BtoA, bool SameType, class A, class B>
struct return_type_2_ifthenelsereturn;
// if A can be converted to B and vice versa -> ambiguous
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, true, false, A, B> {
typedef
detail::return_type_deduction_failure<return_type_2_ifthenelsereturn> type;
// ambiguous type in conditional expression
};
// if A can be converted to B and vice versa and are of same type
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, true, true, A, B> {
typedef A type;
};
// A can be converted to B
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, true, false, false, A, B> {
typedef B type;
};
// B can be converted to A
template<int Phase, class A, class B>
struct return_type_2_ifthenelsereturn<Phase, false, true, false, A, B> {
typedef A type;
};
// neither can be converted. Then we drop the potential references, and
// try again
template<class A, class B>
struct return_type_2_ifthenelsereturn<1, false, false, false, A, B> {
// it is safe to add const, since the result will be an rvalue and thus
// const anyway. The const are needed eg. if the types
// are 'const int*' and 'void *'. The remaining type should be 'const void*'
typedef const typename boost::remove_reference<A>::type plainA;
typedef const typename boost::remove_reference<B>::type plainB;
// TODO: Add support for volatile ?
typedef typename
return_type_2_ifthenelsereturn<
2,
boost::is_convertible<plainA,plainB>::value,
boost::is_convertible<plainB,plainA>::value,
boost::is_same<plainA,plainB>::value,
plainA,
plainB>::type type;
};
// PHASE 6:2
template<class A, class B>
struct return_type_2_ifthenelsereturn<2, false, false, false, A, B> {
typedef
detail::return_type_deduction_failure<return_type_2_ifthenelsereturn> type;
// types_do_not_match_in_conditional_expression
};
// PHASE 5: now we know that types are not arithmetic.
template<class A, class B>
struct non_numeric_types {
typedef typename
return_type_2_ifthenelsereturn<
1, // phase 1
is_convertible<A,B>::value,
is_convertible<B,A>::value,
is_same<A,B>::value,
A,
B>::type type;
};
// PHASE 4 :
// the base case covers arithmetic types with differing promote codes
// use the type deduction of arithmetic_actions
template<int CodeA, int CodeB, class A, class B>
struct arithmetic_or_not {
typedef typename
return_type_2<arithmetic_action<plus_action>, A, B>::type type;
// plus_action is just a random pick, has to be a concrete instance
};
// this case covers the case of artihmetic types with the same promote codes.
// non numeric deduction is used since e.g. integral promotion is not
// performed with operator ?:
template<int CodeA, class A, class B>
struct arithmetic_or_not<CodeA, CodeA, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
// if either A or B has promote code -1 it is not an arithmetic type
template<class A, class B>
struct arithmetic_or_not <-1, -1, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
template<int CodeB, class A, class B>
struct arithmetic_or_not <-1, CodeB, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
template<int CodeA, class A, class B>
struct arithmetic_or_not <CodeA, -1, A, B> {
typedef typename non_numeric_types<A, B>::type type;
};
// PHASE 3 : Are the types same?
// No, check if they are arithmetic or not
template <class A, class B>
struct same_or_not {
typedef typename detail::remove_reference_and_cv<A>::type plainA;
typedef typename detail::remove_reference_and_cv<B>::type plainB;
typedef typename
arithmetic_or_not<
detail::promote_code<plainA>::value,
detail::promote_code<plainB>::value,
A,
B>::type type;
};
// Yes, clear.
template <class A> struct same_or_not<A, A> {
typedef A type;
};
} // detail
// PHASE 2 : Perform first the potential array_to_pointer conversion
template<class A, class B>
struct return_type_2<other_action<ifthenelsereturn_action>, A, B> {
typedef typename detail::array_to_pointer<A>::type A1;
typedef typename detail::array_to_pointer<B>::type B1;
typedef typename
boost::add_const<typename detail::same_or_not<A1, B1>::type>::type type;
};
// PHASE 1 : Deduction is based on the second and third operand
// return type specialization for conditional expression ends -----------
// Control loop lambda_functor_base specializations.
// Specialization for for_loop.
template<class Args>
class
lambda_functor_base<forloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<3>(args), CALL_ACTUAL_ARGS);
}
};
// No body case
template<class Args>
class
lambda_functor_base<forloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
for(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS)) {}
}
};
// Specialization for while_loop.
template<class Args>
class
lambda_functor_base<whileloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
}
};
// No body case
template<class Args>
class
lambda_functor_base<whileloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
while(detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) {}
}
};
// Specialization for do_while_loop.
// Note that the first argument is the condition.
template<class Args>
class
lambda_functor_base<dowhileloop_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
do {
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
} while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) );
}
};
// No body case
template<class Args>
class
lambda_functor_base<dowhileloop_no_body_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
do {} while (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS) );
}
};
// Specialization for if_then.
template<class Args>
class
lambda_functor_base<ifthen_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
}
};
// Specialization for if_then_else.
template<class Args>
class
lambda_functor_base<ifthenelse_action, Args> {
public:
Args args;
template <class T> struct sig { typedef void type; };
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
if (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS))
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
else
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
}
};
// Specialization of lambda_functor_base for if_then_else_return.
template<class Args>
class
lambda_functor_base<other_action<ifthenelsereturn_action>, Args> {
public:
Args args;
template <class SigArgs> struct sig {
private:
typedef typename detail::nth_return_type_sig<1, Args, SigArgs>::type ret1;
typedef typename detail::nth_return_type_sig<2, Args, SigArgs>::type ret2;
public:
typedef typename return_type_2<
other_action<ifthenelsereturn_action>, ret1, ret2
>::type type;
};
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
return (detail::select(boost::tuples::get<0>(args), CALL_ACTUAL_ARGS)) ?
detail::select(boost::tuples::get<1>(args), CALL_ACTUAL_ARGS)
:
detail::select(boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
}
};
} // lambda
} // boost
#endif // BOOST_LAMBDA_CONTROL_CONSTRUCTS_HPP

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - function_adaptors.hpp ---------------------------- // Boost Lambda Library - function_adaptors.hpp ----------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -12,170 +12,25 @@
#ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP #ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
#define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP #define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
#include "boost/mpl/has_xxx.hpp"
#include "boost/tuple/tuple.hpp"
#include "boost/type_traits/same_traits.hpp" #include "boost/type_traits/same_traits.hpp"
#include "boost/type_traits/remove_reference.hpp"
#include "boost/type_traits/remove_cv.hpp"
#include "boost/type_traits/add_const.hpp"
#include "boost/type_traits/add_volatile.hpp"
#include "boost/utility/result_of.hpp"
namespace boost { namespace boost {
namespace lambda { namespace lambda {
namespace detail {
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(sig)
template<class Tuple>
struct remove_references_from_elements {
typedef typename boost::tuples::cons<
typename boost::remove_reference<typename Tuple::head_type>::type,
typename remove_references_from_elements<typename Tuple::tail_type>::type
> type;
};
template<>
struct remove_references_from_elements<boost::tuples::null_type> {
typedef boost::tuples::null_type type;
};
}
template <class Func> struct function_adaptor { template <class Func> struct function_adaptor {
typedef typename detail::remove_reference_and_cv<Func>::type plainF;
#if !defined(BOOST_NO_RESULT_OF)
// Support functors that use the boost::result_of return type convention.
template<class Tuple, int Length, bool HasSig>
struct result_converter;
template<class Tuple, int Length>
struct result_converter<Tuple, Length, true>
: plainF::template sig<
typename detail::remove_references_from_elements<Tuple>::type
>
{};
template<class Tuple>
struct result_converter<Tuple, 0, false>
: result_of<plainF()>
{};
template<class Tuple>
struct result_converter<Tuple, 1, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 2, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 3, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 4, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 5, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type,
typename tuples::element<5, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 6, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type,
typename tuples::element<5, Tuple>::type,
typename tuples::element<6, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 7, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type,
typename tuples::element<5, Tuple>::type,
typename tuples::element<6, Tuple>::type,
typename tuples::element<7, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 8, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type,
typename tuples::element<5, Tuple>::type,
typename tuples::element<6, Tuple>::type,
typename tuples::element<7, Tuple>::type,
typename tuples::element<8, Tuple>::type)
>
{};
template<class Tuple>
struct result_converter<Tuple, 9, false>
: result_of<plainF(
typename tuples::element<1, Tuple>::type,
typename tuples::element<2, Tuple>::type,
typename tuples::element<3, Tuple>::type,
typename tuples::element<4, Tuple>::type,
typename tuples::element<5, Tuple>::type,
typename tuples::element<6, Tuple>::type,
typename tuples::element<7, Tuple>::type,
typename tuples::element<8, Tuple>::type,
typename tuples::element<9, Tuple>::type)
>
{};
// we do not know the return type off-hand, we must ask it from Func // we do not know the return type off-hand, we must ask it from Func
// To sig we pass a cons list, where the head is the function object type template <class Args> class sig {
// itself (potentially cv-qualified) typedef typename Args::head_type F;
// and the tail contains the types of the actual arguments to be passed
// to the function object. The arguments can be cv qualified
// as well.
template <class Args>
struct sig
: result_converter<
Args
, tuples::length<typename Args::tail_type>::value
, detail::has_sig<plainF>::value
>
{};
#else // BOOST_NO_RESULT_OF
template <class Args> class sig {
typedef typename detail::remove_reference_and_cv<Func>::type plainF; typedef typename detail::remove_reference_and_cv<Func>::type plainF;
public: public:
typedef typename plainF::template sig< // To sig we pass a cons list, where the head is the function object type
typename detail::remove_references_from_elements<Args>::type // itself (potentially cv-qualified)
>::type type; // and the tail contains the types of the actual arguments to be passed
// to the function object. The arguments can be cv qualified
// as well.
typedef typename plainF::template sig<Args>::type type;
}; };
#endif
template<class RET, class A1> template<class RET, class A1>
static RET apply(A1& a1) { static RET apply(A1& a1) {
@@ -240,26 +95,22 @@ struct function_adaptor<T Object::*> {
// the data member is accessed is const, and finally adding a reference // the data member is accessed is const, and finally adding a reference
template<class Args> class sig { template<class Args> class sig {
typedef typename boost::tuples::element<1, Args>::type argument_type; typedef typename boost::tuples::element<1, Args>::type argument_type;
typedef typename boost::remove_reference<
argument_type
>::type unref_type;
typedef typename detail::IF<boost::is_const<unref_type>::value, typedef typename detail::IF<boost::is_const<argument_type>::value,
typename boost::add_const<T>::type, typename boost::add_const<T>::type,
T T
>::RET properly_consted_return_type; >::RET properly_consted_return_type;
typedef typename detail::IF<boost::is_volatile<unref_type>::value, typedef typename detail::IF<
boost::is_volatile<properly_consted_return_type>::value,
typename boost::add_volatile<properly_consted_return_type>::type, typename boost::add_volatile<properly_consted_return_type>::type,
properly_consted_return_type properly_consted_return_type
>::RET properly_cvd_return_type; >::RET properly_cvd_return_type;
public: public:
typedef typename detail::IF<boost::is_reference<argument_type>::value, typedef typename
typename boost::add_reference<properly_cvd_return_type>::type, boost::add_reference<properly_cvd_return_type>::type type;
typename boost::remove_cv<T>::type
>::RET type;
}; };
template <class RET> template <class RET>

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - is_instance_of.hpp --------------------- // Boost Lambda Library - is_instance_of.hpp ---------------------
// Copyright (C) 2001 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - lambda_config.hpp ------------------------------ // Boost Lambda Library - lambda_config.hpp ------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -22,6 +22,13 @@
# define BOOST_REF_TO_FUNC_CONFLICTS_WITH_REF_TO_T # define BOOST_REF_TO_FUNC_CONFLICTS_WITH_REF_TO_T
# define BOOST_LAMBDA_INCORRECT_BIND_OVERLOADING # define BOOST_LAMBDA_INCORRECT_BIND_OVERLOADING
# endif # endif
# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97)
# define BOOST_NO_TEMPLATED_STREAMS
# define BOOST_LAMBDA_INCORRECT_BIND_OVERLOADING
# endif
# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)
# define BOOST_LAMBDA_FAILS_IN_TEMPLATE_KEYWORD_AFTER_SCOPE_OPER
# endif
# endif // __GNUC__ # endif // __GNUC__

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library lambda_functor_base.hpp ----------------------------- // Boost Lambda Library lambda_functor_base.hpp -----------------------------
// //
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -13,19 +13,9 @@
#ifndef BOOST_LAMBDA_LAMBDA_FUNCTOR_BASE_HPP #ifndef BOOST_LAMBDA_LAMBDA_FUNCTOR_BASE_HPP
#define BOOST_LAMBDA_LAMBDA_FUNCTOR_BASE_HPP #define BOOST_LAMBDA_LAMBDA_FUNCTOR_BASE_HPP
#include "boost/type_traits/add_reference.hpp"
#include "boost/type_traits/add_const.hpp"
#include "boost/type_traits/remove_const.hpp"
#include "boost/lambda/detail/lambda_fwd.hpp"
#include "boost/lambda/detail/lambda_traits.hpp"
namespace boost { namespace boost {
namespace lambda { namespace lambda {
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif
// for return type deductions we wrap bound argument to this class, // for return type deductions we wrap bound argument to this class,
// which fulfils the base class contract for lambda_functors // which fulfils the base class contract for lambda_functors
@@ -46,16 +36,12 @@ public:
explicit identity(par_t t) : elem(t) {} explicit identity(par_t t) : elem(t) {}
template <typename SigArgs> template <typename SigArgs>
struct sig { typedef typename boost::remove_const<element_t>::type type; }; struct sig { typedef element_t type; };
template<class RET, CALL_TEMPLATE_ARGS> template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const { CALL_USE_ARGS; return elem; } RET call(CALL_FORMAL_ARGS) const { CALL_USE_ARGS; return elem; }
}; };
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
template <class T> template <class T>
inline lambda_functor<identity<T&> > var(T& t) { return identity<T&>(t); } inline lambda_functor<identity<T&> > var(T& t) { return identity<T&>(t); }
@@ -276,8 +262,6 @@ class lambda_functor_base<explicit_return_type_action<RET>, Args>
public: public:
Args args; Args args;
typedef RET result_type;
explicit lambda_functor_base(const Args& a) : args(a) {} explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig { typedef RET type; }; template <class SigArgs> struct sig { typedef RET type; };
@@ -353,7 +337,7 @@ class lambda_functor_base<action<0, Act>, Args>
{ {
public: public:
// Args args; not needed // Args args; not needed
explicit lambda_functor_base(const Args& /*a*/) {} explicit lambda_functor_base(const Args& a) {}
template<class SigArgs> struct sig { template<class SigArgs> struct sig {
typedef typename return_type_N<Act, null_type>::type type; typedef typename return_type_N<Act, null_type>::type type;
@@ -383,7 +367,7 @@ public: \
\ \
template<class SigArgs> struct sig { \ template<class SigArgs> struct sig { \
typedef typename \ typedef typename \
detail::deduce_argument_types<Args, SigArgs>::type rets_t; \ detail::deduce_non_ref_argument_types<Args, SigArgs>::type rets_t; \
public: \ public: \
typedef typename \ typedef typename \
return_type_N_prot<Act, rets_t>::type type; \ return_type_N_prot<Act, rets_t>::type type; \

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - lambda_functors.hpp ------------------------------- // Boost Lambda Library - lambda_functors.hpp -------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -13,31 +13,6 @@
#ifndef BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP #ifndef BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP
#define BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP #define BOOST_LAMBDA_LAMBDA_FUNCTORS_HPP
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/utility/result_of.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
#include <boost/mpl/or.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_array.hpp>
#define BOOST_LAMBDA_DISABLE_IF_ARRAY1(A1, R1)\
typename lazy_disable_if<is_array<A1>, typename R1 >::type
#define BOOST_LAMBDA_DISABLE_IF_ARRAY2(A1, A2, R1, R2) \
typename lazy_disable_if<mpl::or_<is_array<A1>, is_array<A2> >, typename R1, R2 >::type
#define BOOST_LAMBDA_DISABLE_IF_ARRAY3(A1, A2, A3, R1, R2, R3) \
typename lazy_disable_if<mpl::or_<is_array<A1>, is_array<A2>, is_array<A3> >, typename R1, R2, R3 >::type
#else
#define BOOST_LAMBDA_DISABLE_IF_ARRAY1(A1, R1) typename R1::type
#define BOOST_LAMBDA_DISABLE_IF_ARRAY2(A1, A2, R1, R2) typename R1, R2::type
#define BOOST_LAMBDA_DISABLE_IF_ARRAY3(A1, A2, A3, R1, R2, R3) typename R1, R2, R3::type
#endif
namespace boost { namespace boost {
namespace lambda { namespace lambda {
@@ -130,10 +105,7 @@ typedef const lambda_functor<placeholder<THIRD> > placeholder3_type;
// other lambda_functors. // other lambda_functors.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(push)
#pragma warning(disable:4512) //assignment operator could not be generated
#endif
// -- lambda_functor NONE ------------------------------------------------ // -- lambda_functor NONE ------------------------------------------------
template <class T> template <class T>
@@ -162,25 +134,6 @@ public:
inherited::template sig<null_type>::type inherited::template sig<null_type>::type
nullary_return_type; nullary_return_type;
// Support for boost::result_of.
template <class Sig> struct result;
template <class F>
struct result<F()> {
typedef nullary_return_type type;
};
template <class F, class A>
struct result<F(A)> {
typedef typename sig<tuple<F, A> >::type type;
};
template <class F, class A, class B>
struct result<F(A, B)> {
typedef typename sig<tuple<F, A, B> >::type type;
};
template <class F, class A, class B, class C>
struct result<F(A, B, C)> {
typedef typename sig<tuple<F, A, B, C> >::type type;
};
nullary_return_type operator()() const { nullary_return_type operator()() const {
return inherited::template return inherited::template
call<nullary_return_type> call<nullary_return_type>
@@ -196,7 +149,7 @@ public:
} }
template<class A> template<class A>
BOOST_LAMBDA_DISABLE_IF_ARRAY1(A, inherited::template sig<tuple<A const&> >) typename inherited::template sig<tuple<A const&> >::type
operator()(A const& a) const { operator()(A const& a) const {
return inherited::template call< return inherited::template call<
typename inherited::template sig<tuple<A const&> >::type typename inherited::template sig<tuple<A const&> >::type
@@ -212,7 +165,7 @@ public:
} }
template<class A, class B> template<class A, class B>
BOOST_LAMBDA_DISABLE_IF_ARRAY2(A, B, inherited::template sig<tuple<A const&, B&> >) typename inherited::template sig<tuple<A const&, B&> >::type
operator()(A const& a, B& b) const { operator()(A const& a, B& b) const {
return inherited::template call< return inherited::template call<
typename inherited::template sig<tuple<A const&, B&> >::type typename inherited::template sig<tuple<A const&, B&> >::type
@@ -220,7 +173,7 @@ public:
} }
template<class A, class B> template<class A, class B>
BOOST_LAMBDA_DISABLE_IF_ARRAY2(A, B, inherited::template sig<tuple<A&, B const&> >) typename inherited::template sig<tuple<A&, B const&> >::type
operator()(A& a, B const& b) const { operator()(A& a, B const& b) const {
return inherited::template call< return inherited::template call<
typename inherited::template sig<tuple<A&, B const&> >::type typename inherited::template sig<tuple<A&, B const&> >::type
@@ -228,7 +181,7 @@ public:
} }
template<class A, class B> template<class A, class B>
BOOST_LAMBDA_DISABLE_IF_ARRAY2(A, B, inherited::template sig<tuple<A const&, B const&> >) typename inherited::template sig<tuple<A const&, B const&> >::type
operator()(A const& a, B const& b) const { operator()(A const& a, B const& b) const {
return inherited::template call< return inherited::template call<
typename inherited::template sig<tuple<A const&, B const&> >::type typename inherited::template sig<tuple<A const&, B const&> >::type
@@ -245,7 +198,7 @@ public:
} }
template<class A, class B, class C> template<class A, class B, class C>
BOOST_LAMBDA_DISABLE_IF_ARRAY3(A, B, C, inherited::template sig<tuple<A const&, B const&, C const&> >) typename inherited::template sig<tuple<A const&, B const&, C const&> >::type
operator()(A const& a, B const& b, C const& c) const operator()(A const& a, B const& b, C const& c) const
{ {
return inherited::template call< return inherited::template call<
@@ -291,45 +244,10 @@ public:
} }
}; };
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
#pragma warning(pop)
#endif
} // namespace lambda } // namespace lambda
} // namespace boost } // namespace boost
namespace boost {
#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE)
template<class T>
struct result_of<boost::lambda::lambda_functor<T>()>
{
typedef typename boost::lambda::lambda_functor<T>::nullary_return_type type;
};
template<class T>
struct result_of<const boost::lambda::lambda_functor<T>()>
{
typedef typename boost::lambda::lambda_functor<T>::nullary_return_type type;
};
#endif
template<class T>
struct tr1_result_of<boost::lambda::lambda_functor<T>()>
{
typedef typename boost::lambda::lambda_functor<T>::nullary_return_type type;
};
template<class T>
struct tr1_result_of<const boost::lambda::lambda_functor<T>()>
{
typedef typename boost::lambda::lambda_functor<T>::nullary_return_type type;
};
}
// is_placeholder // is_placeholder
#include <boost/is_placeholder.hpp> #include <boost/is_placeholder.hpp>

View File

@@ -1,6 +1,6 @@
// lambda_fwd.hpp - Boost Lambda Library ------------------------------- // lambda_fwd.hpp - Boost Lambda Library -------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// - lambda_traits.hpp --- Boost Lambda Library ---------------------------- // - lambda_traits.hpp --- Boost Lambda Library ----------------------------
// //
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -16,7 +16,6 @@
#include "boost/type_traits/cv_traits.hpp" #include "boost/type_traits/cv_traits.hpp"
#include "boost/type_traits/function_traits.hpp" #include "boost/type_traits/function_traits.hpp"
#include "boost/type_traits/object_traits.hpp" #include "boost/type_traits/object_traits.hpp"
#include "boost/tuple/tuple.hpp"
namespace boost { namespace boost {
namespace lambda { namespace lambda {
@@ -282,11 +281,6 @@ struct const_copy_argument<void> {
typedef void type; typedef void type;
}; };
template<>
struct const_copy_argument<void const> {
typedef void type;
};
// Does the same as const_copy_argument, but passes references through as such // Does the same as const_copy_argument, but passes references through as such
template<class T> template<class T>
@@ -436,56 +430,6 @@ struct bind_traits<const volatile T[n]> {
typedef const volatile T (&type)[n]; typedef const volatile T (&type)[n];
}; };
template<class R>
struct bind_traits<R()> {
typedef R(&type)();
};
template<class R, class Arg1>
struct bind_traits<R(Arg1)> {
typedef R(&type)(Arg1);
};
template<class R, class Arg1, class Arg2>
struct bind_traits<R(Arg1, Arg2)> {
typedef R(&type)(Arg1, Arg2);
};
template<class R, class Arg1, class Arg2, class Arg3>
struct bind_traits<R(Arg1, Arg2, Arg3)> {
typedef R(&type)(Arg1, Arg2, Arg3);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4, Arg5)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4, Arg5);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8);
};
template<class R, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9>
struct bind_traits<R(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)> {
typedef R(&type)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9);
};
template<class T> template<class T>
struct bind_traits<reference_wrapper<T> >{ struct bind_traits<reference_wrapper<T> >{
typedef T& type; typedef T& type;

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library -- member_ptr.hpp --------------------- // Boost Lambda Library -- member_ptr.hpp ---------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000 Gary Powell (gary.powell@sierra.com) // Copyright (C) 2000 Gary Powell (gary.powell@sierra.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,6 +1,6 @@
// -- operator_actions.hpp - Boost Lambda Library ---------------------- // -- operator_actions.hpp - Boost Lambda Library ----------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - operator_lambda_func_base.hpp ----------------- // Boost Lambda Library - operator_lambda_func_base.hpp -----------------
// //
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,6 +1,6 @@
// operator_return_type_traits.hpp -- Boost Lambda Library ------------------ // operator_return_type_traits.hpp -- Boost Lambda Library ------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -12,16 +12,9 @@
#define BOOST_LAMBDA_OPERATOR_RETURN_TYPE_TRAITS_HPP #define BOOST_LAMBDA_OPERATOR_RETURN_TYPE_TRAITS_HPP
#include "boost/lambda/detail/is_instance_of.hpp" #include "boost/lambda/detail/is_instance_of.hpp"
#include "boost/type_traits/is_same.hpp" #include "boost/type_traits/same_traits.hpp"
#include "boost/type_traits/is_pointer.hpp"
#include "boost/type_traits/is_float.hpp"
#include "boost/type_traits/is_convertible.hpp"
#include "boost/type_traits/remove_pointer.hpp"
#include "boost/type_traits/remove_const.hpp"
#include "boost/type_traits/remove_reference.hpp"
#include "boost/indirect_reference.hpp" #include "boost/indirect_reference.hpp"
#include "boost/detail/container_fwd.hpp"
#include <cstddef> // needed for the ptrdiff_t #include <cstddef> // needed for the ptrdiff_t
#include <iosfwd> // for istream and ostream #include <iosfwd> // for istream and ostream
@@ -65,6 +58,10 @@ template <> struct promote_code<long double> { static const int value = 700; };
} // namespace lambda } // namespace lambda
} // namespace boost } // namespace boost
namespace std {
template<class T> class complex;
}
namespace boost { namespace boost {
namespace lambda { namespace lambda {
namespace detail { namespace detail {
@@ -231,15 +228,34 @@ template <> struct contentsof_type<null_type> {
template <class A> struct contentsof_type<const A> { template <class A> struct contentsof_type<const A> {
typedef typename contentsof_type<A>::type type; typedef typename contentsof_type<A>::type type1;
// return a reference to the underlying const type
// the IF is because the A::reference in the primary template could
// be some class type rather than a real reference, hence
// we do not want to make it a reference here either
typedef typename detail::IF<
is_reference<type1>::value,
const typename boost::remove_reference<type1>::type &,
const type1
>::RET type;
}; };
template <class A> struct contentsof_type<volatile A> { template <class A> struct contentsof_type<volatile A> {
typedef typename contentsof_type<A>::type type; typedef typename contentsof_type<A>::type type1;
typedef typename detail::IF<
is_reference<type1>::value,
volatile typename boost::remove_reference<type1>::type &,
volatile type1
>::RET type;
}; };
template <class A> struct contentsof_type<const volatile A> { template <class A> struct contentsof_type<const volatile A> {
typedef typename contentsof_type<A>::type type; typedef typename contentsof_type<A>::type type1;
typedef typename detail::IF<
is_reference<type1>::value,
const volatile typename boost::remove_reference<type1>::type &,
const volatile type1
>::RET type;
}; };
// standard iterator traits should take care of the pointer types // standard iterator traits should take care of the pointer types
@@ -542,6 +558,36 @@ struct return_type_2<bitwise_action<Act>, A, B>
namespace detail { namespace detail {
#ifdef BOOST_NO_TEMPLATED_STREAMS
template<class A, class B>
struct leftshift_type {
typedef typename detail::IF<
boost::is_convertible<
typename boost::remove_reference<A>::type*,
std::ostream*
>::value,
std::ostream&,
typename detail::remove_reference_and_cv<A>::type
>::RET type;
};
template<class A, class B>
struct rightshift_type {
typedef typename detail::IF<
boost::is_convertible<
typename boost::remove_reference<A>::type*,
std::istream*
>::value,
std::istream&,
typename detail::remove_reference_and_cv<A>::type
>::RET type;
};
#else
template <class T> struct get_ostream_type { template <class T> struct get_ostream_type {
typedef std::basic_ostream<typename T::char_type, typedef std::basic_ostream<typename T::char_type,
@@ -578,6 +624,7 @@ public:
}; };
#endif
} // end detail } // end detail
@@ -806,6 +853,44 @@ struct return_type_2<other_action<subscript_action>, A, B> {
}; };
} // namespace lambda
} // namespace boost
// 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
#include <deque>
#else
namespace std {
template <class T, class Allocator> class deque;
}
#endif
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;
}
#endif
namespace boost {
namespace lambda {
template<class Key, class T, class Cmp, class Allocator, class B> template<class Key, class T, class Cmp, class Allocator, class B>
struct plain_return_type_2<other_action<subscript_action>, std::map<Key, T, Cmp, Allocator>, B> { struct plain_return_type_2<other_action<subscript_action>, std::map<Key, T, Cmp, Allocator>, B> {
typedef T& type; typedef T& type;
@@ -848,41 +933,6 @@ struct plain_return_type_2<other_action<subscript_action>, const std::basic_stri
typedef typename std::basic_string<Char, Traits, Allocator>::const_reference type; typedef typename std::basic_string<Char, Traits, Allocator>::const_reference type;
}; };
template<class Char, class Traits, class Allocator>
struct plain_return_type_2<arithmetic_action<plus_action>,
std::basic_string<Char, Traits, Allocator>,
std::basic_string<Char, Traits, Allocator> > {
typedef std::basic_string<Char, Traits, Allocator> type;
};
template<class Char, class Traits, class Allocator>
struct plain_return_type_2<arithmetic_action<plus_action>,
const Char*,
std::basic_string<Char, Traits, Allocator> > {
typedef std::basic_string<Char, Traits, Allocator> type;
};
template<class Char, class Traits, class Allocator>
struct plain_return_type_2<arithmetic_action<plus_action>,
std::basic_string<Char, Traits, Allocator>,
const Char*> {
typedef std::basic_string<Char, Traits, Allocator> type;
};
template<class Char, class Traits, class Allocator, std::size_t N>
struct plain_return_type_2<arithmetic_action<plus_action>,
Char[N],
std::basic_string<Char, Traits, Allocator> > {
typedef std::basic_string<Char, Traits, Allocator> type;
};
template<class Char, class Traits, class Allocator, std::size_t N>
struct plain_return_type_2<arithmetic_action<plus_action>,
std::basic_string<Char, Traits, Allocator>,
Char[N]> {
typedef std::basic_string<Char, Traits, Allocator> type;
};
} // namespace lambda } // namespace lambda
} // namespace boost } // namespace boost

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library - operators.hpp -------------------------------------- // Boost Lambda Library - operators.hpp --------------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -37,16 +37,16 @@ inline const \
lambda_functor< \ lambda_functor< \
lambda_functor_base< \ lambda_functor_base< \
ACTION, \ ACTION, \
tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type> \ tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type> \
> \ > \
> \ > \
OPER_NAME (const lambda_functor<Arg>& a, CONSTB& b) { \ OPER_NAME (const lambda_functor<Arg>& a, CONSTB& b) { \
return \ return \
lambda_functor_base< \ lambda_functor_base< \
ACTION, \ ACTION, \
tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>\ tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type> \
> \ > \
(tuple<lambda_functor<Arg>, typename const_copy_argument <CONSTB>::type>(a, b)); \ (tuple<lambda_functor<Arg>, typename CONVERSION <CONSTB>::type>(a, b)); \
} }
@@ -161,6 +161,23 @@ namespace detail {
// Note that the overloading is const vs. non-const first argument // Note that the overloading is const vs. non-const first argument
#ifdef BOOST_NO_TEMPLATED_STREAMS
template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default {
typedef typename detail::IF<
boost::is_convertible<T*, std::ostream*>::value,
T&,
typename const_copy_argument <T>::type
>::RET type;
};
template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default {
typedef typename detail::IF<
boost::is_convertible<T*, std::istream*>::value,
T&,
typename const_copy_argument <T>::type
>::RET type;
};
#else
template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default { template<class T> struct convert_ostream_to_ref_others_to_c_plain_by_default {
typedef typename detail::IF< typedef typename detail::IF<
@@ -181,6 +198,7 @@ template<class T> struct convert_istream_to_ref_others_to_c_plain_by_default {
typename const_copy_argument <T>::type typename const_copy_argument <T>::type
>::RET type; >::RET type;
}; };
#endif
} // detail } // detail
@@ -240,17 +258,17 @@ operator>>(const lambda_functor<Arg>& a, Ret(&b)(ManipArg))
#error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E1" #error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E1"
#endif #endif
#define BOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONSTB) \ #define BOOST_LAMBDA_PTR_ARITHMETIC_E1(OPER_NAME, ACTION, CONSTB) \
template<class Arg, int N, class B> \ template<class Arg, int N, class B> \
inline const \ inline const \
lambda_functor< \ lambda_functor< \
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \ lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
> \ > \
OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \ OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \
{ \ { \
return \ return lambda_functor< \
lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \ lambda_functor_base<ACTION, tuple<lambda_functor<Arg>, CONSTB(&)[N]> > \
(tuple<lambda_functor<Arg>, CONSTB(&)[N]>(a, b)); \ >(tuple<lambda_functor<Arg>, CONSTB(&)[N]>(a, b)); \
} }
@@ -258,15 +276,15 @@ OPER_NAME (const lambda_functor<Arg>& a, CONSTB(&b)[N]) \
#error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E2" #error "Multiple defines of BOOST_LAMBDA_PTR_ARITHMETIC_E2"
#endif #endif
#define BOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONSTA) \ #define BOOST_LAMBDA_PTR_ARITHMETIC_E2(OPER_NAME, ACTION, CONSTA) \
template<int N, class A, class Arg> \ template<int N, class A, class Arg> \
inline const \ inline const \
lambda_functor< \ lambda_functor< \
lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \ lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
> \ > \
OPER_NAME (CONSTA(&a)[N], const lambda_functor<Arg>& b) \ OPER_NAME (CONSTA(&a)[N], const lambda_functor<Arg>& b) \
{ \ { \
return \ return \
lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \ lambda_functor_base<ACTION, tuple<CONSTA(&)[N], lambda_functor<Arg> > > \
(tuple<CONSTA(&)[N], lambda_functor<Arg> >(a, b)); \ (tuple<CONSTA(&)[N], lambda_functor<Arg> >(a, b)); \
} }

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library ret.hpp ----------------------------------------- // Boost Lambda Library ret.hpp -----------------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -284,7 +284,7 @@ inline const
lambda_functor< lambda_functor<
lambda_functor_base<do_nothing_action, null_type> lambda_functor_base<do_nothing_action, null_type>
> >
make_void(const Arg1&) { make_void(const Arg1& a1) {
return return
lambda_functor_base<do_nothing_action, null_type>(); lambda_functor_base<do_nothing_action, null_type>();
} }

View File

@@ -1,6 +1,6 @@
// return_type_traits.hpp -- Boost Lambda Library --------------------------- // return_type_traits.hpp -- Boost Lambda Library ---------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -19,6 +19,10 @@
namespace boost { namespace boost {
namespace lambda { namespace lambda {
using ::boost::type_traits::ice_and;
using ::boost::type_traits::ice_or;
using ::boost::type_traits::ice_not;
// Much of the type deduction code for standard arithmetic types // Much of the type deduction code for standard arithmetic types
// from Gary Powell // from Gary Powell
@@ -73,7 +77,8 @@ template <class Act, class A> struct return_type_1_prot {
public: public:
typedef typename typedef typename
detail::IF< detail::IF<
is_protectable<Act>::value && is_lambda_functor<A>::value, // is_protectable<Act>::value && is_lambda_functor<A>::value,
ice_and<is_protectable<Act>::value, is_lambda_functor<A>::value>::value,
lambda_functor< lambda_functor<
lambda_functor_base< lambda_functor_base<
Act, Act,
@@ -107,7 +112,9 @@ namespace detail {
// add const to rvalues, so that all rvalues are stored as const in // add const to rvalues, so that all rvalues are stored as const in
// the args tuple // the args tuple
typedef typename detail::IF_type< typedef typename detail::IF_type<
boost::is_reference<T>::value && !boost::is_const<non_ref_T>::value, // boost::is_reference<T>::value && !boost::is_const<non_ref_T>::value,
ice_and<boost::is_reference<T>::value,
ice_not<boost::is_const<non_ref_T>::value>::value>::value,
detail::identity_mapping<T>, detail::identity_mapping<T>,
const_copy_argument<non_ref_T> // handles funtion and array const_copy_argument<non_ref_T> // handles funtion and array
>::type type; // types correctly >::type type; // types correctly
@@ -141,8 +148,11 @@ template <class Act, class A, class B> struct return_type_2_prot {
typedef typename typedef typename
detail::IF< detail::IF<
is_protectable<Act>::value && // is_protectable<Act>::value &&
(is_lambda_functor<A>::value || is_lambda_functor<B>::value), // (is_lambda_functor<A>::value || is_lambda_functor<B>::value),
ice_and<is_protectable<Act>::value,
ice_or<is_lambda_functor<A>::value,
is_lambda_functor<B>::value>::value>::value,
lambda_functor< lambda_functor<
lambda_functor_base< lambda_functor_base<
Act, Act,
@@ -177,8 +187,11 @@ struct return_type_2_comma
typedef typename typedef typename
detail::IF< detail::IF<
is_protectable<other_action<comma_action> >::value && // it is protectable // is_protectable<other_action<comma_action> >::value && // it is protectable
(is_lambda_functor<A>::value || is_lambda_functor<B>::value), // (is_lambda_functor<A>::value || is_lambda_functor<B>::value),
ice_and<is_protectable<other_action<comma_action> >::value, // it is protectable
ice_or<is_lambda_functor<A>::value,
is_lambda_functor<B>::value>::value>::value,
lambda_functor< lambda_functor<
lambda_functor_base< lambda_functor_base<
other_action<comma_action>, other_action<comma_action>,
@@ -203,6 +216,8 @@ typedef typename
// currently there are no protectable actions with > 2 args // currently there are no protectable actions with > 2 args
// Note, that if there will be, lambda_functor_base will have to be
// changed to not get rid of references in Args elements
template<class Act, class Args> struct return_type_N_prot { template<class Act, class Args> struct return_type_N_prot {
typedef typename return_type_N<Act, Args>::type type; typedef typename return_type_N<Act, Args>::type type;

View File

@@ -1,6 +1,6 @@
// -- select_functions.hpp -- Boost Lambda Library -------------------------- // -- select_functions.hpp -- Boost Lambda Library --------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -1,27 +0,0 @@
// Boost Lambda Library suppress_unused.hpp -----------------------------
//
// Copyright (C) 2009 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
// ------------------------------------------------------------
#ifndef BOOST_LAMBDA_SUPPRESS_UNUSED_HPP
#define BOOST_LAMBDA_SUPPRESS_UNUSED_HPP
namespace boost {
namespace lambda {
namespace detail {
template<class T>
inline void suppress_unused_variable_warnings(const T&) {}
}
}
}
#endif

View File

@@ -1,7 +1,7 @@
// -- Boost Lambda Library -- exceptions.hpp ---------------- // -- Boost Lambda Library -- exceptions.hpp ----------------
// //
// Copyright (C) 2000 Gary Powell (gwpowell@hotmail.com) // Copyright (C) 2000 Gary Powell (gwpowell@hotmail.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -14,7 +14,6 @@
#if !defined(BOOST_LAMBDA_EXCEPTIONS_HPP) #if !defined(BOOST_LAMBDA_EXCEPTIONS_HPP)
#define BOOST_LAMBDA_EXCEPTIONS_HPP #define BOOST_LAMBDA_EXCEPTIONS_HPP
#include "boost/lambda/core.hpp"
#include "boost/lambda/detail/control_constructs_common.hpp" #include "boost/lambda/detail/control_constructs_common.hpp"
namespace boost { namespace boost {

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library -- if.hpp ------------------------------------------ // Boost Lambda Library -- if.hpp ------------------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (C) 2001-2002 Joel de Guzman // Copyright (C) 2001-2002 Joel de Guzman
// //
@@ -345,7 +345,7 @@ public:
// is true, the true_statement (again an lambda_functor) is executed // is true, the true_statement (again an lambda_functor) is executed
// otherwise, the false_statement (another lambda_functor) is executed. The // otherwise, the false_statement (another lambda_functor) is executed. The
// result type of this is void. Note the trailing underscore after // result type of this is void. Note the trailing underscore after
// if_ and the leading dot and the trailing underscore before // if_ and the the leading dot and the trailing underscore before
// and after .else_. // and after .else_.
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@@ -1,5 +1,5 @@
// -- lambda.hpp -- Boost Lambda Library ----------------------------------- // -- lambda.hpp -- Boost Lambda Library -----------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -24,6 +24,11 @@
#include "boost/lambda/detail/operators.hpp" #include "boost/lambda/detail/operators.hpp"
#ifndef BOOST_LAMBDA_FAILS_IN_TEMPLATE_KEYWORD_AFTER_SCOPE_OPER
// sorry, member ptr does not work with gcc2.95
#include "boost/lambda/detail/member_ptr.hpp" #include "boost/lambda/detail/member_ptr.hpp"
#endif
#endif #endif

View File

@@ -1,6 +1,6 @@
// Boost Lambda Library -- loops.hpp ---------------------------------------- // Boost Lambda Library -- loops.hpp ----------------------------------------
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (c) 2001-2002 Joel de Guzman // Copyright (c) 2001-2002 Joel de Guzman
// //
@@ -348,7 +348,7 @@ while_(CondT const& cond)
// While the condition (an lambda_functor) evaluates to true, statement // While the condition (an lambda_functor) evaluates to true, statement
// (another lambda_functor) is executed. The statement is executed at least // (another lambda_functor) is executed. The statement is executed at least
// once. The result type of this is void. Note the trailing // once. The result type of this is void. Note the trailing
// underscore after do_ and the leading dot and the trailing // underscore after do_ and the the leading dot and the trailing
// underscore before and after .while_. // underscore before and after .while_.
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@@ -1,5 +1,5 @@
// -- numeric.hpp -- Boost Lambda Library ----------------------------------- // -- numeric.hpp -- Boost Lambda Library -----------------------------------
// Copyright (C) 2002 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2002 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com) // Copyright (C) 2002 Gary Powell (gwpowell@hotmail.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,7 +1,7 @@
// Boost Lambda Library -- switch.hpp ----------------------------------- // Boost Lambda Library -- switch.hpp -----------------------------------
// //
// Copyright (C) 2000 Gary Powell (powellg@amazon.com) // Copyright (C) 2000 Gary Powell (powellg@amazon.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -465,18 +465,12 @@ BOOST_LAMBDA_SWITCH( BOOST_PP_INC(N) )
#define BOOST_LAMBDA_SWITCH_STATEMENT_HELPER(z, N, A) \ #define BOOST_LAMBDA_SWITCH_STATEMENT_HELPER(z, N, A) \
BOOST_LAMBDA_SWITCH_STATEMENT(BOOST_PP_INC(N)) BOOST_LAMBDA_SWITCH_STATEMENT(BOOST_PP_INC(N))
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4065)
#endif
// up to 9 cases supported (counting default:) // up to 9 cases supported (counting default:)
BOOST_PP_REPEAT_2ND(9,BOOST_LAMBDA_SWITCH_HELPER,FOO) BOOST_PP_REPEAT_2ND(9,BOOST_LAMBDA_SWITCH_HELPER,FOO)
BOOST_PP_REPEAT_2ND(9,BOOST_LAMBDA_SWITCH_STATEMENT_HELPER,FOO) BOOST_PP_REPEAT_2ND(9,BOOST_LAMBDA_SWITCH_STATEMENT_HELPER,FOO)
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} // namespace lambda } // namespace lambda
} // namespace boost } // namespace boost

View File

@@ -1,15 +0,0 @@
{
"key": "lambda",
"name": "Lambda",
"authors": [
"Jaakko Järvi",
"Gary Powell"
],
"description": "Define small unnamed function objects at the actual call site, and more.",
"category": [
"Function-objects"
],
"maintainers": [
"Jaakko Jarvi <jarvi -at- cs.tamu.edu>"
]
}

View File

@@ -11,7 +11,7 @@
import testing ; import testing ;
project project
: requirements <toolset>msvc:<asynch-exceptions>on : requirements <library>/boost/test//boost_test_exec_monitor
; ;
test-suite lambda test-suite lambda
@@ -30,6 +30,4 @@ test-suite lambda
[ run operator_tests_simple.cpp ] [ run operator_tests_simple.cpp ]
[ run phoenix_control_structures.cpp ] [ run phoenix_control_structures.cpp ]
[ run switch_construct.cpp ] [ run switch_construct.cpp ]
[ run result_of_tests.cpp ]
[ run ret_test.cpp ]
; ;

View File

@@ -1,6 +1,6 @@
// bll_and_function.cpp - The Boost Lambda Library ----------------------- // bll_and_function.cpp - The Boost Lambda Library -----------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,8 +1,7 @@
// bind_tests_advanced.cpp -- The Boost Lambda Library ------------------ // bind_tests_advanced.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// Copyright (C) 2010 Steven Watanabe
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
@@ -20,9 +19,6 @@
#include "boost/any.hpp" #include "boost/any.hpp"
#include "boost/type_traits/is_reference.hpp"
#include "boost/mpl/assert.hpp"
#include "boost/mpl/if.hpp"
#include <iostream> #include <iostream>
@@ -31,8 +27,7 @@
#include <algorithm> #include <algorithm>
using namespace boost::lambda; using namespace boost::lambda;
namespace bl = boost::lambda;
int sum_0() { return 0; } int sum_0() { return 0; }
int sum_1(int a) { return a; } int sum_1(int a) { return a; }
@@ -96,7 +91,7 @@ int call_with_100(const F& f) {
// This would result in; // This would result in;
// bind(_1 + 1, _1)(make_const(100)) , which would be a compile time error // bind(_1 + 1, _1)(make_const(100)) , which would be a compile time error
return bl::bind(unlambda(f), _1)(make_const(100)); return bind(unlambda(f), _1)(make_const(100));
// for other functors than lambda functors, unlambda has no effect // for other functors than lambda functors, unlambda has no effect
// (except for making them const) // (except for making them const)
@@ -121,19 +116,11 @@ void test_unlambda() {
BOOST_CHECK(call_with_101(_1 + 1) == 102); BOOST_CHECK(call_with_101(_1 + 1) == 102);
#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) BOOST_CHECK(call_with_100(bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
BOOST_CHECK(call_with_100(bl::bind(std_functor(std::bind1st(std::plus<int>(), 1)), _1)) == 101);
#else
BOOST_CHECK(call_with_100(bl::bind(std_functor(std::bind(std::plus<int>(), 1, std::placeholders::_1)), _1)) == 101);
#endif
// std_functor insturcts LL that the functor defines a result_type typedef // std_functor insturcts LL that the functor defines a result_type typedef
// rather than a sig template. // rather than a sig template.
bl::bind(std_functor(std::plus<int>()), _1, _2)(i, i); bind(std_functor(std::plus<int>()), _1, _2)(i, i);
} }
@@ -364,55 +351,6 @@ void test_break_const()
BOOST_CHECK(i == 3); BOOST_CHECK(i == 3);
} }
template<class T>
struct func {
template<class Args>
struct sig {
typedef typename boost::tuples::element<1, Args>::type arg1;
// If the argument type is not the same as the expected type,
// return void, which will cause an error. Note that we
// can't just assert that the types are the same, because
// both const and non-const versions can be instantiated
// even though only one is ultimately used.
typedef typename boost::mpl::if_<boost::is_same<arg1, T>,
typename boost::remove_const<arg1>::type,
void
>::type type;
};
template<class U>
U operator()(const U& arg) const {
return arg;
}
};
void test_sig()
{
int i = 1;
BOOST_CHECK(bind(func<int>(), 1)() == 1);
BOOST_CHECK(bind(func<const int>(), _1)(static_cast<const int&>(i)) == 1);
BOOST_CHECK(bind(func<int>(), _1)(i) == 1);
}
class base {
public:
virtual int foo() = 0;
};
class derived : public base {
public:
virtual int foo() {
return 1;
}
};
void test_abstract()
{
derived d;
base& b = d;
BOOST_CHECK(bind(&base::foo, var(b))() == 1);
BOOST_CHECK(bind(&base::foo, *_1)(&b) == 1);
}
int test_main(int, char *[]) { int test_main(int, char *[]) {
test_nested_binds(); test_nested_binds();
@@ -422,7 +360,17 @@ int test_main(int, char *[]) {
test_const_parameters(); test_const_parameters();
test_rvalue_arguments(); test_rvalue_arguments();
test_break_const(); test_break_const();
test_sig();
test_abstract();
return 0; return 0;
} }

View File

@@ -1,6 +1,6 @@
// bind_tests_simple.cpp -- The Boost Lambda Library ------------------ // bind_tests_simple.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -18,7 +18,9 @@
#include <iostream> #include <iostream>
using namespace boost::lambda;
using namespace std;
using namespace boost::lambda;
int sum_of_args_0() { return 0; } int sum_of_args_0() { return 0; }
@@ -80,23 +82,6 @@ void test_member_functions()
// bind(&A::add, a, _1); // bind(&A::add, a, _1);
} }
struct B {
B(int n) : i(n) {};
int i;
};
void test_data_members()
{
using boost::ref;
B b(10);
BOOST_CHECK(bind(&B::i, ref(b))() == 10);
BOOST_CHECK(bind(&B::i, b)() == 10);
BOOST_CHECK(bind(&B::i, _1)(b) == 10);
BOOST_CHECK(bind(&B::i, _1)(B(11)) == 11);
bind(&B::i, ref(b))() = 1;
BOOST_CHECK(b.i == 1);
}
int test_main(int, char *[]) { int test_main(int, char *[]) {
int i = 1; int j = 2; int k = 3; int i = 1; int j = 2; int k = 3;

View File

@@ -1,6 +1,6 @@
// bind_tests_simple.cpp -- The Boost Lambda Library ------------------ // bind_tests_simple.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -18,7 +18,9 @@
#include <iostream> #include <iostream>
using namespace boost::lambda;
using namespace std;
using namespace boost::lambda;
int sum_of_args_0() { return 0; } int sum_of_args_0() { return 0; }

View File

@@ -1,6 +1,6 @@
// bll_and_function.cpp - The Boost Lambda Library ----------------------- // bll_and_function.cpp - The Boost Lambda Library -----------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,6 +1,6 @@
// cast_tests.cpp -- The Boost Lambda Library ------------------ // cast_tests.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -29,7 +29,7 @@ class base {
public: public:
virtual std::string class_name() const { return "const base"; } virtual std::string class_name() const { return "const base"; }
virtual std::string class_name() { return "base"; } virtual std::string class_name() { return "base"; }
virtual ~base() {}
}; };
class derived : public base { class derived : public base {

View File

@@ -1,6 +1,6 @@
// constructor_tests.cpp -- The Boost Lambda Library ------------------ // constructor_tests.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -24,12 +24,8 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#ifdef BOOST_MSVC
#pragma warning(disable:4512)
#endif
using namespace boost::lambda; using namespace boost::lambda;
namespace bl = boost::lambda; using namespace std;
template<class T> template<class T>
bool check_tuple(int n, const T& t) bool check_tuple(int n, const T& t)
@@ -38,7 +34,7 @@ bool check_tuple(int n, const T& t)
} }
template <> template <>
bool check_tuple(int /*n*/, const null_type& ) { return true; } bool check_tuple(int n, const null_type& ) { return true; }
void constructor_all_lengths() void constructor_all_lengths()
@@ -187,7 +183,7 @@ public:
void test_destructor () void test_destructor ()
{ {
char space[sizeof(is_destructor_called)]; char space[sizeof(is_destructor_called)];
bool flag = false; bool flag;
is_destructor_called* idc = new(space) is_destructor_called(flag); is_destructor_called* idc = new(space) is_destructor_called(flag);
BOOST_CHECK(flag == false); BOOST_CHECK(flag == false);
@@ -212,17 +208,17 @@ int count_deletes::count = 0;
void test_news_and_deletes () void test_news_and_deletes ()
{ {
int* i[10]; int* i[10];
std::for_each(i, i+10, _1 = bind(new_ptr<int>(), 2)); for_each(i, i+10, _1 = bind(new_ptr<int>(), 2));
int count_errors = 0; int count_errors = 0;
std::for_each(i, i+10, (*_1 == 2) || ++var(count_errors)); for_each(i, i+10, (*_1 == 2) || ++var(count_errors));
BOOST_CHECK(count_errors == 0); BOOST_CHECK(count_errors == 0);
count_deletes* ct[10]; count_deletes* ct[10];
std::for_each(ct, ct+10, _1 = bind(new_ptr<count_deletes>())); for_each(ct, ct+10, _1 = bind(new_ptr<count_deletes>()));
count_deletes::count = 0; count_deletes::count = 0;
std::for_each(ct, ct+10, bind(delete_ptr(), _1)); for_each(ct, ct+10, bind(delete_ptr(), _1));
BOOST_CHECK(count_deletes::count == 10); BOOST_CHECK(count_deletes::count == 10);
} }
@@ -240,16 +236,16 @@ void test_array_new_and_delete()
void delayed_construction() void delayed_construction()
{ {
std::vector<int> x(3); vector<int> x(3);
std::vector<int> y(3); vector<int> y(3);
std::fill(x.begin(), x.end(), 0); fill(x.begin(), x.end(), 0);
std::fill(y.begin(), y.end(), 1); fill(y.begin(), y.end(), 1);
std::vector<std::pair<int, int> > v; vector<pair<int, int> > v;
std::transform(x.begin(), x.end(), y.begin(), std::back_inserter(v), transform(x.begin(), x.end(), y.begin(), back_inserter(v),
bl::bind(constructor<std::pair<int, int> >(), _1, _2) ); bind(constructor<pair<int, int> >(), _1, _2) );
} }
int test_main(int, char *[]) { int test_main(int, char *[]) {

View File

@@ -1,6 +1,6 @@
// -- control_structures.cpp -- The Boost Lambda Library ------------------ // -- control_structures.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,6 +1,6 @@
// -- exception_test.cpp -- The Boost Lambda Library ------------------ // -- exception_test.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -29,7 +29,7 @@ using namespace boost::lambda;
using namespace std; using namespace std;
// to prevent unused variables warnings // to prevent unused variables warnings
template <class T> void dummy(const T&) {} template <class T> void dummy(const T& t) {}
void erroneous_exception_related_lambda_expressions() { void erroneous_exception_related_lambda_expressions() {
@@ -603,7 +603,7 @@ int test_main(int, char *[]) {
return_type_matching(); return_type_matching();
test_empty_catch_blocks(); test_empty_catch_blocks();
} }
catch (int) catch (int x)
{ {
BOOST_CHECK(false); BOOST_CHECK(false);
} }

View File

@@ -1,6 +1,6 @@
// extending_return_type_traits.cpp -- The Boost Lambda Library -------- // extending_return_type_traits.cpp -- The Boost Lambda Library --------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -16,7 +16,6 @@
#include "boost/lambda/bind.hpp" #include "boost/lambda/bind.hpp"
#include "boost/lambda/lambda.hpp" #include "boost/lambda/lambda.hpp"
#include "boost/lambda/detail/suppress_unused.hpp"
#include <iostream> #include <iostream>
@@ -24,8 +23,6 @@
#include <algorithm> #include <algorithm>
using boost::lambda::detail::suppress_unused_variable_warnings;
class A {}; class A {};
class B {}; class B {};
@@ -84,7 +81,7 @@ struct plain_return_type_1<other_action<contentsof_action>, A> {
} // lambda } // lambda
} // boost } // boost
void ok(B /*b*/) {} void ok(B b) {}
void test_unary_operators() void test_unary_operators()
{ {
@@ -130,7 +127,7 @@ class my_vector {};
template<class A, class B> template<class A, class B>
my_vector<typename return_type_2<arithmetic_action<plus_action>, A&, B&>::type> my_vector<typename return_type_2<arithmetic_action<plus_action>, A&, B&>::type>
operator+(const my_vector<A>& /*a*/, const my_vector<B>& /*b*/) operator+(const my_vector<A>& a, const my_vector<B>& b)
{ {
typedef typename typedef typename
return_type_2<arithmetic_action<plus_action>, A&, B&>::type res_type; return_type_2<arithmetic_action<plus_action>, A&, B&>::type res_type;
@@ -178,8 +175,8 @@ Z operator^=( X&, const Y&) { return Z(); }
// assignment // assignment
class Assign { class Assign {
public: public:
void operator=(const Assign& /*a*/) {} void operator=(const Assign& a) {}
X operator[](const int& /*i*/) { return X(); } X operator[](const int& i) { return X(); }
}; };
@@ -332,16 +329,9 @@ void test_binary_operators() {
XX dummy3 = (_1 * _2)(vxx, vyy); XX dummy3 = (_1 * _2)(vxx, vyy);
VV dummy4 = (_1 * _2)(cvxx, cvyy); VV dummy4 = (_1 * _2)(cvxx, cvyy);
suppress_unused_variable_warnings(dummy1);
suppress_unused_variable_warnings(dummy2);
suppress_unused_variable_warnings(dummy3);
suppress_unused_variable_warnings(dummy4);
my_vector<int> v1; my_vector<double> v2; my_vector<int> v1; my_vector<double> v2;
my_vector<double> d = (_1 + _2)(v1, v2); my_vector<double> d = (_1 + _2)(v1, v2);
suppress_unused_variable_warnings(d);
// bitwise // bitwise
(_1 << _2)(x, y); (_1 << _2)(x, y);

View File

@@ -1,6 +1,6 @@
// is_instance_of_test.cpp -- The Boost Lambda Library ------------------ // is_instance_of_test.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,6 +1,6 @@
// member_pointer_test.cpp -- The Boost Lambda Library ------------------ // member_pointer_test.cpp -- The Boost Lambda Library ------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -118,11 +118,11 @@ class C {};
class D {}; class D {};
// ->* can be overloaded to do anything // ->* can be overloaded to do anything
bool operator->*(A /*a*/, B /*b*/) { bool operator->*(A a, B b) {
return false; return false;
} }
bool operator->*(B /*b*/, A /*a*/) { bool operator->*(B b, A a) {
return true; return true;
} }

View File

@@ -1,6 +1,6 @@
// operator_tests_simple.cpp -- The Boost Lambda Library --------------- // operator_tests_simple.cpp -- The Boost Lambda Library ---------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
@@ -17,10 +17,6 @@
#include "boost/lambda/lambda.hpp" #include "boost/lambda/lambda.hpp"
#include "boost/lambda/detail/suppress_unused.hpp"
#include <boost/shared_ptr.hpp>
#include <vector> #include <vector>
#include <map> #include <map>
#include <set> #include <set>
@@ -100,8 +96,6 @@ void arithmetic_operators() {
// test that unary plus really does something // test that unary plus really does something
unary_plus_tester u; unary_plus_tester u;
unary_plus_tester up = (+_1)(u); unary_plus_tester up = (+_1)(u);
boost::lambda::detail::suppress_unused_variable_warnings(up);
} }
void bitwise_operators() { void bitwise_operators() {
@@ -235,22 +229,6 @@ void compound_operators() {
(_1 %= 2)(i); (_1 %= 2)(i);
BOOST_CHECK(i == 1); BOOST_CHECK(i == 1);
// lambda expression as a left operand with rvalue on RHS
(_1 += (0 + 1))(i);
BOOST_CHECK(i == 2);
(_1 -= (0 + 1))(i);
BOOST_CHECK(i == 1);
(_1 *= (0 + 10))(i);
BOOST_CHECK(i == 10);
(_1 /= (0 + 2))(i);
BOOST_CHECK(i == 5);
(_1 %= (0 + 2))(i);
BOOST_CHECK(i == 1);
// shifts // shifts
unsigned int ui = 2; unsigned int ui = 2;
(_1 <<= 1)(ui); (_1 <<= 1)(ui);
@@ -341,18 +319,8 @@ void address_of_and_dereference() {
(*_1 = 7)(it); (*_1 = 7)(it);
BOOST_CHECK(vi[0] == 7); BOOST_CHECK(vi[0] == 7);
const std::vector<int>::iterator cit(it);
(*_1 = 8)(cit);
BOOST_CHECK(vi[0] == 8);
// TODO: Add tests for more complex iterator types // TODO: Add tests for more complex iterator types
boost::shared_ptr<int> ptr(new int(0));
(*_1 = 7)(ptr);
BOOST_CHECK(*ptr == 7);
const boost::shared_ptr<int> cptr(ptr);
(*_1 = 8)(cptr);
BOOST_CHECK(*ptr == 8);
} }

View File

@@ -1,6 +1,6 @@
// phoenix_style_control_structures.cpp -- The Boost Lambda Library ------ // phoenix_style_control_structures.cpp -- The Boost Lambda Library ------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See

View File

@@ -1,314 +0,0 @@
// result_of_tests.cpp -- The Boost Lambda Library ------------------
//
// Copyright (C) 2010 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
// -----------------------------------------------------------------------
#include <boost/test/minimal.hpp> // see "Header Implementation Option"
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
struct with_result_type {
typedef int result_type;
int operator()() const { return 0; }
int operator()(int) const { return 1; }
int operator()(int, int) const { return 2; }
int operator()(int, int, int) const { return 3; }
int operator()(int, int, int, int) const { return 4; }
int operator()(int, int, int, int, int) const { return 5; }
int operator()(int, int, int, int, int, int) const { return 6; }
int operator()(int, int, int, int, int, int, int) const { return 7; }
int operator()(int, int, int, int, int, int, int, int) const { return 8; }
int operator()(int, int, int, int, int, int, int, int, int) const { return 9; }
};
struct with_result_template_value {
template<class Sig>
struct result;
template<class This>
struct result<This()> {
typedef int type;
};
template<class This, class A1>
struct result<This(A1)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
typedef int type;
};
template<class This, class A1, class A2>
struct result<This(A1, A2)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3>
struct result<This(A1, A2, A3)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4>
struct result<This(A1, A2, A3, A4)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5>
struct result<This(A1, A2, A3, A4, A5)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
BOOST_MPL_ASSERT((boost::is_same<A5, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6>
struct result<This(A1, A2, A3, A4, A5, A6)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
BOOST_MPL_ASSERT((boost::is_same<A5, int>));
BOOST_MPL_ASSERT((boost::is_same<A6, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
struct result<This(A1, A2, A3, A4, A5, A6, A7)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
BOOST_MPL_ASSERT((boost::is_same<A5, int>));
BOOST_MPL_ASSERT((boost::is_same<A6, int>));
BOOST_MPL_ASSERT((boost::is_same<A7, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
struct result<This(A1, A2, A3, A4, A5, A6, A7, A8)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
BOOST_MPL_ASSERT((boost::is_same<A5, int>));
BOOST_MPL_ASSERT((boost::is_same<A6, int>));
BOOST_MPL_ASSERT((boost::is_same<A7, int>));
BOOST_MPL_ASSERT((boost::is_same<A8, int>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
struct result<This(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int>));
BOOST_MPL_ASSERT((boost::is_same<A2, int>));
BOOST_MPL_ASSERT((boost::is_same<A3, int>));
BOOST_MPL_ASSERT((boost::is_same<A4, int>));
BOOST_MPL_ASSERT((boost::is_same<A5, int>));
BOOST_MPL_ASSERT((boost::is_same<A6, int>));
BOOST_MPL_ASSERT((boost::is_same<A7, int>));
BOOST_MPL_ASSERT((boost::is_same<A8, int>));
BOOST_MPL_ASSERT((boost::is_same<A9, int>));
typedef int type;
};
int operator()() const { return 0; }
int operator()(int) const { return 1; }
int operator()(int, int) const { return 2; }
int operator()(int, int, int) const { return 3; }
int operator()(int, int, int, int) const { return 4; }
int operator()(int, int, int, int, int) const { return 5; }
int operator()(int, int, int, int, int, int) const { return 6; }
int operator()(int, int, int, int, int, int, int) const { return 7; }
int operator()(int, int, int, int, int, int, int, int) const { return 8; }
int operator()(int, int, int, int, int, int, int, int, int) const { return 9; }
};
struct with_result_template_reference {
template<class Sig>
struct result;
template<class This>
struct result<This()> {
typedef int type;
};
template<class This, class A1>
struct result<This(A1)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
typedef int type;
};
template<class This, class A1, class A2>
struct result<This(A1, A2)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3>
struct result<This(A1, A2, A3)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4>
struct result<This(A1, A2, A3, A4)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5>
struct result<This(A1, A2, A3, A4, A5)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
BOOST_MPL_ASSERT((boost::is_same<A5, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6>
struct result<This(A1, A2, A3, A4, A5, A6)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
BOOST_MPL_ASSERT((boost::is_same<A5, int&>));
BOOST_MPL_ASSERT((boost::is_same<A6, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
struct result<This(A1, A2, A3, A4, A5, A6, A7)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
BOOST_MPL_ASSERT((boost::is_same<A5, int&>));
BOOST_MPL_ASSERT((boost::is_same<A6, int&>));
BOOST_MPL_ASSERT((boost::is_same<A7, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
struct result<This(A1, A2, A3, A4, A5, A6, A7, A8)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
BOOST_MPL_ASSERT((boost::is_same<A5, int&>));
BOOST_MPL_ASSERT((boost::is_same<A6, int&>));
BOOST_MPL_ASSERT((boost::is_same<A7, int&>));
BOOST_MPL_ASSERT((boost::is_same<A8, int&>));
typedef int type;
};
template<class This, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
struct result<This(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
BOOST_MPL_ASSERT((boost::is_same<A1, int&>));
BOOST_MPL_ASSERT((boost::is_same<A2, int&>));
BOOST_MPL_ASSERT((boost::is_same<A3, int&>));
BOOST_MPL_ASSERT((boost::is_same<A4, int&>));
BOOST_MPL_ASSERT((boost::is_same<A5, int&>));
BOOST_MPL_ASSERT((boost::is_same<A6, int&>));
BOOST_MPL_ASSERT((boost::is_same<A7, int&>));
BOOST_MPL_ASSERT((boost::is_same<A8, int&>));
BOOST_MPL_ASSERT((boost::is_same<A9, int&>));
typedef int type;
};
int operator()() const { return 0; }
int operator()(int) const { return 1; }
int operator()(int, int) const { return 2; }
int operator()(int, int, int) const { return 3; }
int operator()(int, int, int, int) const { return 4; }
int operator()(int, int, int, int, int) const { return 5; }
int operator()(int, int, int, int, int, int) const { return 6; }
int operator()(int, int, int, int, int, int, int) const { return 7; }
int operator()(int, int, int, int, int, int, int, int) const { return 8; }
int operator()(int, int, int, int, int, int, int, int, int) const { return 9; }
};
template<class F>
typename boost::result_of<F()>::type apply0(F f) {
return f();
}
template<class A, class F>
typename boost::result_of<F(A)>::type apply1(F f, A a) {
return f(a);
}
template<class A, class B, class F>
typename boost::result_of<F(A, B)>::type apply2(F f, A a, B b) {
return f(a, b);
}
template<class A, class B, class C, class F>
typename boost::result_of<F(A, B, C)>::type apply3(F f, A a, B b, C c) {
return f(a, b, c);
}
using namespace boost::lambda;
int test_main(int, char *[]) {
BOOST_CHECK(boost::lambda::bind(with_result_type())() == 0);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1)() == 1);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2)() == 2);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3)() == 3);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4)() == 4);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5)() == 5);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6)() == 6);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7)() == 7);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7, 8)() == 8);
BOOST_CHECK(boost::lambda::bind(with_result_type(), 1, 2, 3, 4, 5, 6, 7, 8, 9)() == 9);
// Nullary result_of fails
//BOOST_CHECK(boost::lambda::bind(with_result_template_value())() == 0);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1)() == 1);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2)() == 2);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3)() == 3);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4)() == 4);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5)() == 5);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6)() == 6);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7)() == 7);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7, 8)() == 8);
BOOST_CHECK(boost::lambda::bind(with_result_template_value(), 1, 2, 3, 4, 5, 6, 7, 8, 9)() == 9);
int one = 1,
two = 2,
three = 3,
four = 4,
five = 5,
six = 6,
seven = 7,
eight = 8,
nine = 9;
// Nullary result_of fails
//BOOST_CHECK(boost::lambda::bind(with_result_template_reference())() == 0);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one))() == 1);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two))() == 2);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three))() == 3);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four))() == 4);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five))() == 5);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six))() == 6);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven))() == 7);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven), var(eight))() == 8);
BOOST_CHECK(boost::lambda::bind(with_result_template_reference(), var(one), var(two), var(three), var(four), var(five), var(six), var(seven), var(eight), var(nine))() == 9);
// Check using result_of with lambda functors
BOOST_CHECK(apply0(constant(0)) == 0);
BOOST_CHECK(apply1<int>(_1, one) == 1);
BOOST_CHECK(apply1<int&>(_1, one) == 1);
BOOST_CHECK(apply1<const int&>(_1, one) == 1);
BOOST_CHECK((apply2<int, int>(_1 + _2, one, two) == 3));
BOOST_CHECK((apply2<int&, int&>(_1 + _2, one, two) == 3));
BOOST_CHECK((apply2<const int&, const int&>(_1 + _2, one, two) == 3));
BOOST_CHECK((apply3<int, int, int>(_1 + _2 + _3, one, two, three) == 6));
BOOST_CHECK((apply3<int&, int&, int&>(_1 + _2 + _3, one, two, three) == 6));
BOOST_CHECK((apply3<const int&, const int&, const int&>(_1 + _2 + _3, one, two, three) == 6));
return 0;
}

View File

@@ -1,53 +0,0 @@
// ret_test.cpp - The Boost Lambda Library -----------------------
//
// Copyright (C) 2009 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
#include <boost/test/minimal.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
template<class R, class F>
void test_ret(R r, F f) {
typename F::result_type x = f();
BOOST_MPL_ASSERT((boost::is_same<R, typename F::result_type>));
BOOST_CHECK(x == r);
}
template<class R, class F, class T1>
void test_ret(R r, F f, T1& t1) {
typename F::result_type x = f(t1);
BOOST_MPL_ASSERT((boost::is_same<R, typename F::result_type>));
BOOST_CHECK(x == r);
}
class add_result {
public:
add_result(int i = 0) : value(i) {}
friend bool operator==(const add_result& lhs, const add_result& rhs) {
return(lhs.value == rhs.value);
}
private:
int value;
};
class addable {};
add_result operator+(addable, addable) {
return add_result(7);
}
int test_main(int, char*[]) {
addable test;
test_ret(add_result(7), boost::lambda::ret<add_result>(boost::lambda::_1 + test), test);
test_ret(8.0, boost::lambda::ret<double>(boost::lambda::constant(7) + 1));
return 0;
}

View File

@@ -1,6 +1,6 @@
// switch_test.cpp -- The Boost Lambda Library -------------------------- // switch_test.cpp -- The Boost Lambda Library --------------------------
// //
// Copyright (C) 2000-2003 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2000-2003 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com) // Copyright (C) 2000-2003 Gary Powell (powellg@amazon.com)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See