Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_mpl_bind.hpp
Go to the documentation of this file.
1 // $Id$
2 // $Source$
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Sacado Package
7 // Copyright (2006) Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // This library is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as
14 // published by the Free Software Foundation; either version 2.1 of the
15 // License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 // USA
26 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
27 // (etphipp@sandia.gov).
28 //
29 // ***********************************************************************
30 // @HEADER
31 
32 #ifndef SACADO_MPL_BIND_HPP
33 #define SACADO_MPL_BIND_HPP
34 
36 #include "Sacado_mpl_is_same.hpp"
38 
39 namespace Sacado {
40 
41  namespace mpl {
42 
43  template <int k, class F, class T1, class T2, class T3, class T4, class T5>
44  struct hk { typedef F type; };
45 
46  template <int k, int N, class T1, class T2, class T3, class T4, class T5>
47  struct hk<k,arg<N>,T1,T2,T3,T4,T5> :
48  apply_wrap<arg<N>,T1,T2,T3,T4,T5> {};
49 
50  template <int k, class T1, class T2, class T3, class T4, class T5>
51  struct hk<k,arg<-1>,T1,T2,T3,T4,T5> :
52  apply_wrap<arg<k>,T1,T2,T3,T4,T5> {};
53 
54  template <class F, class T1>
55  struct bind1 {
56  template <class U1=mpl::none,
57  class U2=mpl::none,
58  class U3=mpl::none,
59  class U4=mpl::none,
60  class U5=mpl::none>
61  struct apply :
62  apply_wrap1<F,
63  typename hk<is_same<T1,placeholders::_>::value,
64  T1,
65  U1,U2,U3,U4,U5>::type> {};
66  };
67 
68  template <class F, class T1, class T2>
69  struct bind2 {
70  template <class U1=mpl::none,
71  class U2=mpl::none,
72  class U3=mpl::none,
73  class U4=mpl::none,
74  class U5=mpl::none>
75  struct apply :
76  apply_wrap2<F,
77  typename hk<is_same<T1,placeholders::_>::value,
78  T1,
79  U1,U2,U3,U4,U5>::type,
80  typename hk<is_same<T1,placeholders::_>::value+
81  is_same<T2,placeholders::_>::value,
82  T2,
83  U1,U2,U3,U4,U5>::type> {};
84  };
85 
86  template <class F, class T1, class T2, class T3>
87  struct bind3 {
88  template <class U1=mpl::none,
89  class U2=mpl::none,
90  class U3=mpl::none,
91  class U4=mpl::none,
92  class U5=mpl::none>
93  struct apply :
94  apply_wrap3<F,
95  typename hk<is_same<T1,placeholders::_>::value,
96  T1,
97  U1,U2,U3,U4,U5>::type,
98  typename hk<is_same<T1,placeholders::_>::value+
99  is_same<T2,placeholders::_>::value,
100  T2,
101  U1,U2,U3,U4,U5>::type,
102  typename hk<is_same<T1,placeholders::_>::value+
103  is_same<T2,placeholders::_>::value+
104  is_same<T3,placeholders::_>::value,
105  T3,
106  U1,U2,U3,U4,U5>::type> {};
107  };
108 
109  template <class F, class T1, class T2, class T3, class T4>
110  struct bind4 {
111  template <class U1=mpl::none,
112  class U2=mpl::none,
113  class U3=mpl::none,
114  class U4=mpl::none,
115  class U5=mpl::none>
116  struct apply :
117  apply_wrap4<F,
118  typename hk<is_same<T1,placeholders::_>::value,
119  T1,
120  U1,U2,U3,U4,U5>::type,
121  typename hk<is_same<T1,placeholders::_>::value+
122  is_same<T2,placeholders::_>::value,
123  T2,
124  U1,U2,U3,U4,U5>::type,
125  typename hk<is_same<T1,placeholders::_>::value+
126  is_same<T2,placeholders::_>::value+
127  is_same<T3,placeholders::_>::value,
128  T3,
129  U1,U2,U3,U4,U5>::type,
130  typename hk<is_same<T1,placeholders::_>::value+
131  is_same<T2,placeholders::_>::value+
132  is_same<T3,placeholders::_>::value+
133  is_same<T4,placeholders::_>::value,
134  T4,
135  U1,U2,U3,U4,U5>::type> {};
136  };
137 
138  template <class F, class T1, class T2, class T3, class T4, class T5>
139  struct bind5 {
140  template <class U1=mpl::none,
141  class U2=mpl::none,
142  class U3=mpl::none,
143  class U4=mpl::none,
144  class U5=mpl::none>
145  struct apply :
146  apply_wrap5<F,
147  typename hk<is_same<T1,placeholders::_>::value,
148  T1,
149  U1,U2,U3,U4,U5>::type,
150  typename hk<is_same<T1,placeholders::_>::value+
151  is_same<T2,placeholders::_>::value,
152  T2,
153  U1,U2,U3,U4,U5>::type,
154  typename hk<is_same<T1,placeholders::_>::value+
155  is_same<T2,placeholders::_>::value+
156  is_same<T3,placeholders::_>::value,
157  T3,
158  U1,U2,U3,U4,U5>::type,
159  typename hk<is_same<T1,placeholders::_>::value+
160  is_same<T2,placeholders::_>::value+
161  is_same<T3,placeholders::_>::value+
162  is_same<T4,placeholders::_>::value,
163  T4,
164  U1,U2,U3,U4,U5>::type,
165  typename hk<is_same<T1,placeholders::_>::value+
166  is_same<T2,placeholders::_>::value+
167  is_same<T3,placeholders::_>::value+
168  is_same<T4,placeholders::_>::value+
169  is_same<T5,placeholders::_>::value,
170  T5,
171  U1,U2,U3,U4,U5>::type> {};
172  };
173 
174  } // namespace mpl
175 
176 } // namespace Sacado
177 
178 #endif // SACADO_MPL_BIND_HPP
#define T2(r, f)
Definition: Sacado_rad.hpp:578
#define T1(r, f)
Definition: Sacado_rad.hpp:603
const int N