Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:06

0001 // -- Boost Lambda Library - actions.hpp ----------------------------------
0002 
0003 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 // For more information, see www.boost.org
0010 
0011 // ----------------------------------------------------------------
0012 
0013 #ifndef BOOST_LAMBDA_ACTIONS_HPP
0014 #define BOOST_LAMBDA_ACTIONS_HPP
0015 
0016 namespace boost { 
0017 namespace lambda {
0018 
0019 
0020 
0021 template<int Arity, class Act> class action;
0022 
0023 // these need to be defined here, since the corresponding lambda 
0024 // functions are members of lambda_functor classes
0025 
0026 class assignment_action {};
0027 class subscript_action {};
0028 
0029 template <class Action> class other_action;
0030 
0031 // action for specifying the explicit return type
0032 template <class RET> class explicit_return_type_action {};
0033 
0034 // action for preventing the expansion of a lambda expression
0035 struct protect_action {};
0036 
0037   // must be defined here, comma is a special case
0038 struct comma_action {};
0039 
0040 
0041   // actions, for which the existence of protect is checked in return type 
0042   // deduction.
0043 
0044 template <class Action> struct is_protectable {
0045   BOOST_STATIC_CONSTANT(bool, value = false);
0046 };
0047 
0048 // NOTE: comma action is protectable. Other protectable actions
0049 // are listed in operator_actions.hpp
0050 
0051 template<> struct is_protectable<other_action<comma_action> > {
0052   BOOST_STATIC_CONSTANT(bool, value = true);
0053 };
0054 
0055 
0056 namespace detail {
0057 
0058   // this type is used in return type deductions to signal that deduction 
0059   // did not find a result. It does not necessarily mean an error, it commonly
0060   // means that something else should be tried.
0061   class unspecified {};
0062 }
0063 
0064   // function action is a special case: bind functions can be called with 
0065   // the return type specialized explicitly e.g. bind<int>(foo);
0066   // If this call syntax is used, the return type is stored in the latter
0067   // argument of function_action template. Otherwise the argument gets the type
0068   // 'unspecified'.
0069   // This argument is only relevant in the return type deduction code
0070 template <int I, class Result_type = detail::unspecified> 
0071 class function_action {};
0072    
0073 template<class T> class function_action<1, T> {
0074 public:
0075   template<class RET, class A1>
0076   static RET apply(A1& a1) {
0077     return function_adaptor<typename boost::remove_cv<A1>::type>::
0078       template apply<RET>(a1);
0079   }
0080 };
0081 
0082 template<class T> class function_action<2, T> {
0083 public:
0084   template<class RET, class A1, class A2>
0085   static RET apply(A1& a1, A2& a2) {
0086     return function_adaptor<typename boost::remove_cv<A1>::type>::
0087       template apply<RET>(a1, a2);
0088   }
0089 };
0090 
0091 template<class T> class function_action<3, T> {
0092 public:
0093   template<class RET, class A1, class A2, class A3>
0094   static RET apply(A1& a1, A2& a2, A3& a3) {
0095     return function_adaptor<typename boost::remove_cv<A1>::type>::
0096       template apply<RET>(a1, a2, a3);
0097   }
0098 };
0099 
0100 template<class T> class function_action<4, T> {
0101 public:
0102   template<class RET, class A1, class A2, class A3, class A4>
0103   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4) {
0104     return function_adaptor<typename boost::remove_cv<A1>::type>::
0105       template apply<RET>(a1, a2, a3, a4);
0106   }
0107 };
0108 
0109 template<class T> class function_action<5, T> {
0110 public:
0111   template<class RET, class A1, class A2, class A3, class A4, class A5>
0112   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
0113     return function_adaptor<typename boost::remove_cv<A1>::type>::
0114       template apply<RET>(a1, a2, a3, a4, a5);
0115   }
0116 };
0117 
0118 template<class T> class function_action<6, T> {
0119 public:
0120   template<class RET, class A1, class A2, class A3, class A4, class A5, 
0121            class A6>
0122   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
0123     return function_adaptor<typename boost::remove_cv<A1>::type>::
0124       template apply<RET>(a1, a2, a3, a4, a5, a6);
0125   }
0126 };
0127 
0128 template<class T> class function_action<7, T> {
0129 public:
0130   template<class RET, class A1, class A2, class A3, class A4, class A5,  
0131            class A6, class A7>
0132   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
0133     return function_adaptor<typename boost::remove_cv<A1>::type>::
0134       template apply<RET>(a1, a2, a3, a4, a5, a6, a7);
0135   }
0136 };
0137 
0138 template<class T> class function_action<8, T> {
0139 public:
0140   template<class RET, class A1, class A2, class A3, class A4, class A5, 
0141            class A6, class A7, class A8>
0142   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, 
0143                    A8& a8) {
0144     return function_adaptor<typename boost::remove_cv<A1>::type>::
0145       template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8);
0146   }
0147 };
0148 
0149 template<class T> class function_action<9, T> {
0150 public:
0151   template<class RET, class A1, class A2, class A3, class A4, class A5, 
0152            class A6, class A7, class A8, class A9>
0153   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, 
0154                    A8& a8, A9& a9) {
0155     return function_adaptor<typename boost::remove_cv<A1>::type>::
0156       template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8, a9);
0157   }
0158 };
0159 
0160 template<class T> class function_action<10, T> {
0161 public:
0162   template<class RET, class A1, class A2, class A3, class A4, class A5, 
0163            class A6, class A7, class A8, class A9, class A10>
0164   static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, 
0165                    A8& a8, A9& a9, A10& a10) {
0166     return function_adaptor<typename boost::remove_cv<A1>::type>::
0167       template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
0168   }
0169 };
0170 
0171 } // namespace lambda
0172 } // namespace boost
0173 
0174 #endif