123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- #ifndef BOOST_LAMBDA_RET_HPP
- #define BOOST_LAMBDA_RET_HPP
- namespace boost {
- namespace lambda {
-
-
-
-
-
-
-
-
-
- template<class RET, class Arg>
- inline const
- lambda_functor<
- lambda_functor_base<
- explicit_return_type_action<RET>,
- tuple<lambda_functor<Arg> >
- >
- >
- ret(const lambda_functor<Arg>& a1)
- {
- return
- lambda_functor_base<
- explicit_return_type_action<RET>,
- tuple<lambda_functor<Arg> >
- >
- (tuple<lambda_functor<Arg> >(a1));
- }
-
- template <class T>
- inline const T& protect(const T& t) { return t; }
- template<class Arg>
- inline const
- lambda_functor<
- lambda_functor_base<
- protect_action,
- tuple<lambda_functor<Arg> >
- >
- >
- protect(const lambda_functor<Arg>& a1)
- {
- return
- lambda_functor_base<
- protect_action,
- tuple<lambda_functor<Arg> >
- >
- (tuple<lambda_functor<Arg> >(a1));
- }
-
- template <class LambdaFunctor>
- class non_lambda_functor
- {
- LambdaFunctor lf;
- public:
-
-
-
- template <class SigArgs> struct sig {
- typedef typename
- LambdaFunctor::inherited::
- template sig<typename SigArgs::tail_type>::type type;
- };
- explicit non_lambda_functor(const LambdaFunctor& a) : lf(a) {}
- typename LambdaFunctor::nullary_return_type
- operator()() const {
- return lf.template
- call<typename LambdaFunctor::nullary_return_type>
- (cnull_type(), cnull_type(), cnull_type(), cnull_type());
- }
- template<class A>
- typename sig<tuple<const non_lambda_functor, A&> >::type
- operator()(A& a) const {
- return lf.template call<typename sig<tuple<const non_lambda_functor, A&> >::type >(a, cnull_type(), cnull_type(), cnull_type());
- }
- template<class A, class B>
- typename sig<tuple<const non_lambda_functor, A&, B&> >::type
- operator()(A& a, B& b) const {
- return lf.template call<typename sig<tuple<const non_lambda_functor, A&, B&> >::type >(a, b, cnull_type(), cnull_type());
- }
- template<class A, class B, class C>
- typename sig<tuple<const non_lambda_functor, A&, B&, C&> >::type
- operator()(A& a, B& b, C& c) const {
- return lf.template call<typename sig<tuple<const non_lambda_functor, A&, B&, C&> >::type>(a, b, c, cnull_type());
- }
- };
- template <class Arg>
- inline const Arg& unlambda(const Arg& a) { return a; }
- template <class Arg>
- inline const non_lambda_functor<lambda_functor<Arg> >
- unlambda(const lambda_functor<Arg>& a)
- {
- return non_lambda_functor<lambda_functor<Arg> >(a);
- }
-
-
-
-
- template <class LambdaFunctor>
- struct const_incorrect_lambda_functor {
- LambdaFunctor lf;
- public:
- explicit const_incorrect_lambda_functor(const LambdaFunctor& a) : lf(a) {}
- template <class SigArgs> struct sig {
- typedef typename
- LambdaFunctor::inherited::template
- sig<typename SigArgs::tail_type>::type type;
- };
-
- template<class A>
- typename sig<tuple<const const_incorrect_lambda_functor, A&> >::type
- operator()(const A& a) const {
- return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&> >::type >(const_cast<A&>(a), cnull_type(), cnull_type(), cnull_type());
- }
- template<class A, class B>
- typename sig<tuple<const const_incorrect_lambda_functor, A&, B&> >::type
- operator()(const A& a, const B& b) const {
- return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&, B&> >::type >(const_cast<A&>(a), const_cast<B&>(b), cnull_type(), cnull_type());
- }
- template<class A, class B, class C>
- typename sig<tuple<const const_incorrect_lambda_functor, A&, B&, C&> >::type
- operator()(const A& a, const B& b, const C& c) const {
- return lf.template call<typename sig<tuple<const const_incorrect_lambda_functor, A&, B&, C&> >::type>(const_cast<A&>(a), const_cast<B&>(b), const_cast<C&>(c), cnull_type());
- }
- };
- template <class LambdaFunctor>
- struct const_parameter_lambda_functor {
- LambdaFunctor lf;
- public:
- explicit const_parameter_lambda_functor(const LambdaFunctor& a) : lf(a) {}
- template <class SigArgs> struct sig {
- typedef typename
- LambdaFunctor::inherited::template
- sig<typename SigArgs::tail_type>::type type;
- };
-
- template<class A>
- typename sig<tuple<const const_parameter_lambda_functor, const A&> >::type
- operator()(const A& a) const {
- return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&> >::type >(a, cnull_type(), cnull_type(), cnull_type());
- }
- template<class A, class B>
- typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&> >::type
- operator()(const A& a, const B& b) const {
- return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&> >::type >(a, b, cnull_type(), cnull_type());
- }
- template<class A, class B, class C>
- typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&, const C&>
- >::type
- operator()(const A& a, const B& b, const C& c) const {
- return lf.template call<typename sig<tuple<const const_parameter_lambda_functor, const A&, const B&, const C&> >::type>(a, b, c, cnull_type());
- }
- };
- template <class Arg>
- inline const const_incorrect_lambda_functor<lambda_functor<Arg> >
- break_const(const lambda_functor<Arg>& lf)
- {
- return const_incorrect_lambda_functor<lambda_functor<Arg> >(lf);
- }
- template <class Arg>
- inline const const_parameter_lambda_functor<lambda_functor<Arg> >
- const_parameters(const lambda_functor<Arg>& lf)
- {
- return const_parameter_lambda_functor<lambda_functor<Arg> >(lf);
- }
- struct voidifier_action {
- template<class Ret, class A> static void apply(A&) {}
- };
- template<class Args> struct return_type_N<voidifier_action, Args> {
- typedef void type;
- };
- template<class Arg1>
- inline const
- lambda_functor<
- lambda_functor_base<
- action<1, voidifier_action>,
- tuple<lambda_functor<Arg1> >
- >
- >
- make_void(const lambda_functor<Arg1>& a1) {
- return
- lambda_functor_base<
- action<1, voidifier_action>,
- tuple<lambda_functor<Arg1> >
- >
- (tuple<lambda_functor<Arg1> > (a1));
- }
- template<class Arg1>
- inline const
- lambda_functor<
- lambda_functor_base<do_nothing_action, null_type>
- >
- make_void(const Arg1&) {
- return
- lambda_functor_base<do_nothing_action, null_type>();
- }
- template<class T>
- struct result_type_to_sig : public T {
- template<class Args> struct sig { typedef typename T::result_type type; };
- result_type_to_sig(const T& t) : T(t) {}
- };
- template<class F>
- inline result_type_to_sig<F> std_functor(const F& f) { return f; }
- }
- }
- #endif
|