source: NonGTP/Boost/boost/lambda/detail/actions.hpp @ 857

Revision 857, 5.6 KB checked in by igarcia, 19 years ago (diff)
Line 
1// -- Boost Lambda Library - actions.hpp ----------------------------------
2
3// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9// For more information, see www.boost.org
10
11// ----------------------------------------------------------------
12
13#ifndef BOOST_LAMBDA_ACTIONS_HPP
14#define BOOST_LAMBDA_ACTIONS_HPP
15
16namespace boost {
17namespace lambda {
18
19
20
21template<int Arity, class Act> class action;
22
23// these need to be defined here, since the corresponding lambda
24// functions are members of lambda_functor classes
25
26class assignment_action {};
27class subscript_action {};
28
29template <class Action> class other_action;
30
31// action for specifying the explicit return type
32template <class RET> class explicit_return_type_action {};
33
34// action for preventing the expansion of a lambda expression
35struct protect_action {};
36
37  // must be defined here, comma is a special case
38struct comma_action {};
39
40
41  // actions, for which the existence of protect is checked in return type
42  // deduction.
43
44template <class Action> struct is_protectable {
45  BOOST_STATIC_CONSTANT(bool, value = false);
46};
47
48// NOTE: comma action is protectable. Other protectable actions
49// are listed in operator_actions.hpp
50
51template<> struct is_protectable<other_action<comma_action> > {
52  BOOST_STATIC_CONSTANT(bool, value = true);
53};
54
55
56namespace detail {
57
58  // this type is used in return type deductions to signal that deduction
59  // did not find a result. It does not necessarily mean an error, it commonly
60  // means that something else should be tried.
61  class unspecified {};
62}
63
64  // function action is a special case: bind functions can be called with
65  // the return type specialized explicitly e.g. bind<int>(foo);
66  // If this call syntax is used, the return type is stored in the latter
67  // argument of function_action template. Otherwise the argument gets the type
68  // 'unspecified'.
69  // This argument is only relevant in the return type deduction code
70template <int I, class Result_type = detail::unspecified>
71class function_action {};
72   
73template<class T> class function_action<1, T> {
74public:
75  template<class RET, class A1>
76  static RET apply(A1& a1) {
77    return function_adaptor<typename boost::remove_cv<A1>::type>::
78      template apply<RET>(a1);
79  }
80};
81
82template<class T> class function_action<2, T> {
83public:
84  template<class RET, class A1, class A2>
85  static RET apply(A1& a1, A2& a2) {
86    return function_adaptor<typename boost::remove_cv<A1>::type>::
87      template apply<RET>(a1, a2);
88  }
89};
90
91template<class T> class function_action<3, T> {
92public:
93  template<class RET, class A1, class A2, class A3>
94  static RET apply(A1& a1, A2& a2, A3& a3) {
95    return function_adaptor<typename boost::remove_cv<A1>::type>::
96      template apply<RET>(a1, a2, a3);
97  }
98};
99
100template<class T> class function_action<4, T> {
101public:
102  template<class RET, class A1, class A2, class A3, class A4>
103  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4) {
104    return function_adaptor<typename boost::remove_cv<A1>::type>::
105      template apply<RET>(a1, a2, a3, a4);
106  }
107};
108
109template<class T> class function_action<5, T> {
110public:
111  template<class RET, class A1, class A2, class A3, class A4, class A5>
112  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
113    return function_adaptor<typename boost::remove_cv<A1>::type>::
114      template apply<RET>(a1, a2, a3, a4, a5);
115  }
116};
117
118template<class T> class function_action<6, T> {
119public:
120  template<class RET, class A1, class A2, class A3, class A4, class A5,
121           class A6>
122  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
123    return function_adaptor<typename boost::remove_cv<A1>::type>::
124      template apply<RET>(a1, a2, a3, a4, a5, a6);
125  }
126};
127
128template<class T> class function_action<7, T> {
129public:
130  template<class RET, class A1, class A2, class A3, class A4, class A5, 
131           class A6, class A7>
132  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
133    return function_adaptor<typename boost::remove_cv<A1>::type>::
134      template apply<RET>(a1, a2, a3, a4, a5, a6, a7);
135  }
136};
137
138template<class T> class function_action<8, T> {
139public:
140  template<class RET, class A1, class A2, class A3, class A4, class A5,
141           class A6, class A7, class A8>
142  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7,
143                   A8& a8) {
144    return function_adaptor<typename boost::remove_cv<A1>::type>::
145      template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8);
146  }
147};
148
149template<class T> class function_action<9, T> {
150public:
151  template<class RET, class A1, class A2, class A3, class A4, class A5,
152           class A6, class A7, class A8, class A9>
153  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7,
154                   A8& a8, A9& a9) {
155    return function_adaptor<typename boost::remove_cv<A1>::type>::
156      template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8, a9);
157  }
158};
159
160template<class T> class function_action<10, T> {
161public:
162  template<class RET, class A1, class A2, class A3, class A4, class A5,
163           class A6, class A7, class A8, class A9, class A10>
164  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7,
165                   A8& a8, A9& a9, A10& a10) {
166    return function_adaptor<typename boost::remove_cv<A1>::type>::
167      template apply<RET>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
168  }
169};
170
171} // namespace lambda
172} // namespace boost
173
174#endif
Note: See TracBrowser for help on using the repository browser.