MADNESS  version 0.9
function_traits_bits.h
Go to the documentation of this file.
1 #ifndef MADNESS_FUNCTION_TRAITS
2 #define MADNESS_FUNCTION_TRAITS
3 // Used only if we don't have boost or C++0x
4 
5 namespace madness {
6  namespace tr1 {
7  namespace detail {
9  template <typename functionT>
10  struct function_traits : public std::false_type {};
11 
13  template <typename returnT>
14  struct function_traits<returnT(*)()> {
15  static const bool value = true;
16  static const int arity = 0;
17  typedef returnT result_type;
18  };
19 
21  template <typename returnT, typename arg1T>
22  struct function_traits<returnT(*)(arg1T)> {
23  static const bool value = true;
24  static const int arity = 1;
25  typedef returnT result_type;
26  typedef arg1T arg1_type;
27  };
28 
30  template <typename returnT, typename arg1T, typename arg2T>
31  struct function_traits<returnT(*)(arg1T,arg2T)> {
32  static const bool value = true;
33  static const int arity = 2;
34  typedef returnT result_type;
35  typedef arg1T arg1_type;
36  typedef arg2T arg2_type;
37  };
38 
40  template <typename returnT, typename arg1T, typename arg2T, typename arg3T>
41  struct function_traits<returnT(*)(arg1T,arg2T,arg3T)> {
42  static const bool value = true;
43  static const int arity = 3;
44  typedef returnT result_type;
45  typedef arg1T arg1_type;
46  typedef arg2T arg2_type;
47  typedef arg3T arg3_type;
48  };
49 
51  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T>
52  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T)> {
53  static const bool value = true;
54  static const int arity = 4;
55  typedef returnT result_type;
56  typedef arg1T arg1_type;
57  typedef arg2T arg2_type;
58  typedef arg3T arg3_type;
59  typedef arg4T arg4_type;
60  };
61 
63  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T>
64  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T,arg5T)> {
65  static const bool value = true;
66  static const int arity = 5;
67  typedef returnT result_type;
68  typedef arg1T arg1_type;
69  typedef arg2T arg2_type;
70  typedef arg3T arg3_type;
71  typedef arg4T arg4_type;
72  typedef arg5T arg5_type;
73  };
74 
75 
77  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T>
78  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T)> {
79  static const bool value = true;
80  static const int arity = 6;
81  typedef returnT result_type;
82  typedef arg1T arg1_type;
83  typedef arg2T arg2_type;
84  typedef arg3T arg3_type;
85  typedef arg4T arg4_type;
86  typedef arg5T arg5_type;
87  typedef arg6T arg6_type;
88  };
89 
90 
92  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T>
93  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T)> {
94  static const bool value = true;
95  static const int arity = 7;
96  typedef returnT result_type;
97  typedef arg1T arg1_type;
98  typedef arg2T arg2_type;
99  typedef arg3T arg3_type;
100  typedef arg4T arg4_type;
101  typedef arg5T arg5_type;
102  typedef arg6T arg6_type;
103  typedef arg7T arg7_type;
104  };
105 
107  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T>
108  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T)> {
109  static const bool value = true;
110  static const int arity = 8;
111  typedef returnT result_type;
112  typedef arg1T arg1_type;
113  typedef arg2T arg2_type;
114  typedef arg3T arg3_type;
115  typedef arg4T arg4_type;
116  typedef arg5T arg5_type;
117  typedef arg6T arg6_type;
118  typedef arg7T arg7_type;
119  typedef arg8T arg8_type;
120  };
121 
123  template <typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T, typename arg9T>
124  struct function_traits<returnT(*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T,arg9T)> {
125  static const bool value = true;
126  static const int arity = 9;
127  typedef returnT result_type;
128  typedef arg1T arg1_type;
129  typedef arg2T arg2_type;
130  typedef arg3T arg3_type;
131  typedef arg4T arg4_type;
132  typedef arg5T arg5_type;
133  typedef arg6T arg6_type;
134  typedef arg7T arg7_type;
135  typedef arg8T arg8_type;
136  typedef arg9T arg9_type;
137  };
138 
139 
141  template <typename memfuncT>
142  struct memfunc_traits {
143  static const bool value = false;
144  };
145 
147  template <typename objT, typename returnT>
148  struct memfunc_traits<returnT(objT::*)()> {
149  static const bool value = true;
150  static const int arity = 0;
151  static const bool constness = false;
152  typedef objT obj_type;
153  typedef returnT result_type;
154  };
155 
157  template <typename objT, typename returnT, typename arg1T>
158  struct memfunc_traits<returnT(objT::*)(arg1T)> {
159  static const bool value = true;
160  static const int arity = 1;
161  static const bool constness = false;
162  typedef objT obj_type;
163  typedef returnT result_type;
164  typedef arg1T arg1_type;
165  };
166 
168  template <typename objT, typename returnT, typename arg1T, typename arg2T>
169  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T)> {
170  static const bool value = true;
171  static const int arity = 2;
172  static const bool constness = false;
173  typedef objT obj_type;
174  typedef returnT result_type;
175  typedef arg1T arg1_type;
176  typedef arg2T arg2_type;
177  };
178 
180  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T>
181  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T)> {
182  static const bool value = true;
183  static const int arity = 3;
184  static const bool constness = false;
185  typedef objT obj_type;
186  typedef returnT result_type;
187  typedef arg1T arg1_type;
188  typedef arg2T arg2_type;
189  typedef arg3T arg3_type;
190  };
191 
193  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T>
194  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T)> {
195  static const bool value = true;
196  static const int arity = 4;
197  static const bool constness = false;
198  typedef objT obj_type;
199  typedef returnT result_type;
200  typedef arg1T arg1_type;
201  typedef arg2T arg2_type;
202  typedef arg3T arg3_type;
203  typedef arg4T arg4_type;
204  };
205 
206 
208  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T>
209  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T)> {
210  static const bool value = true;
211  static const int arity = 5;
212  static const bool constness = false;
213  typedef objT obj_type;
214  typedef returnT result_type;
215  typedef arg1T arg1_type;
216  typedef arg2T arg2_type;
217  typedef arg3T arg3_type;
218  typedef arg4T arg4_type;
219  typedef arg5T arg5_type;
220  };
221 
222 
224  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T>
225  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T)> {
226  static const bool value = true;
227  static const int arity = 6;
228  static const bool constness = false;
229  typedef objT obj_type;
230  typedef returnT result_type;
231  typedef arg1T arg1_type;
232  typedef arg2T arg2_type;
233  typedef arg3T arg3_type;
234  typedef arg4T arg4_type;
235  typedef arg5T arg5_type;
236  typedef arg6T arg6_type;
237  };
238 
239 
241  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T>
242  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T)> {
243  static const bool value = true;
244  static const int arity = 7;
245  static const bool constness = false;
246  typedef objT obj_type;
247  typedef returnT result_type;
248  typedef arg1T arg1_type;
249  typedef arg2T arg2_type;
250  typedef arg3T arg3_type;
251  typedef arg4T arg4_type;
252  typedef arg5T arg5_type;
253  typedef arg6T arg6_type;
254  typedef arg7T arg7_type;
255  };
256 
257 
259  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T>
260  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T)> {
261  static const bool value = true;
262  static const int arity = 8;
263  static const bool constness = false;
264  typedef objT obj_type;
265  typedef returnT result_type;
266  typedef arg1T arg1_type;
267  typedef arg2T arg2_type;
268  typedef arg3T arg3_type;
269  typedef arg4T arg4_type;
270  typedef arg5T arg5_type;
271  typedef arg6T arg6_type;
272  typedef arg7T arg7_type;
273  typedef arg8T arg8_type;
274  };
275 
276 
278  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T, typename arg9T>
279  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T,arg9T)> {
280  static const bool value = true;
281  static const int arity = 9;
282  static const bool constness = false;
283  typedef objT obj_type;
284  typedef returnT result_type;
285  typedef arg1T arg1_type;
286  typedef arg2T arg2_type;
287  typedef arg3T arg3_type;
288  typedef arg4T arg4_type;
289  typedef arg5T arg5_type;
290  typedef arg6T arg6_type;
291  typedef arg7T arg7_type;
292  typedef arg8T arg8_type;
293  typedef arg9T arg9_type;
294  };
295 
296 
298  template <typename objT, typename returnT>
299  struct memfunc_traits<returnT(objT::*)() const> {
300  static const bool value = true;
301  static const int arity = 0;
302  static const bool constness = true;
303  typedef objT obj_type;
304  typedef returnT result_type;
305  };
306 
308  template <typename objT, typename returnT, typename arg1T>
309  struct memfunc_traits<returnT(objT::*)(arg1T) const> {
310  static const bool value = true;
311  static const int arity = 1;
312  static const bool constness = true;
313  typedef objT obj_type;
314  typedef returnT result_type;
315  typedef arg1T arg1_type;
316  };
317 
319  template <typename objT, typename returnT, typename arg1T, typename arg2T>
320  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T) const> {
321  static const bool value = true;
322  static const int arity = 2;
323  static const bool constness = true;
324  typedef objT obj_type;
325  typedef returnT result_type;
326  typedef arg1T arg1_type;
327  typedef arg2T arg2_type;
328  };
329 
331  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T>
332  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T) const> {
333  static const bool value = true;
334  static const int arity = 3;
335  static const bool constness = true;
336  typedef objT obj_type;
337  typedef returnT result_type;
338  typedef arg1T arg1_type;
339  typedef arg2T arg2_type;
340  typedef arg3T arg3_type;
341  };
342 
343 
345  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T>
346  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T) const> {
347  static const bool value = true;
348  static const int arity = 4;
349  static const bool constness = true;
350  typedef objT obj_type;
351  typedef returnT result_type;
352  typedef arg1T arg1_type;
353  typedef arg2T arg2_type;
354  typedef arg3T arg3_type;
355  typedef arg4T arg4_type;
356  };
357 
358 
359 
361  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T>
362  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T) const> {
363  static const bool value = true;
364  static const int arity = 5;
365  static const bool constness = true;
366  typedef objT obj_type;
367  typedef returnT result_type;
368  typedef arg1T arg1_type;
369  typedef arg2T arg2_type;
370  typedef arg3T arg3_type;
371  typedef arg4T arg4_type;
372  typedef arg5T arg5_type;
373  };
374 
375 
377  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T>
378  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T) const> {
379  static const bool value = true;
380  static const int arity = 6;
381  static const bool constness = true;
382  typedef objT obj_type;
383  typedef returnT result_type;
384  typedef arg1T arg1_type;
385  typedef arg2T arg2_type;
386  typedef arg3T arg3_type;
387  typedef arg4T arg4_type;
388  typedef arg5T arg5_type;
389  typedef arg6T arg6_type;
390  };
391 
392 
394  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T>
395  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T) const> {
396  static const bool value = true;
397  static const int arity = 7;
398  static const bool constness = true;
399  typedef objT obj_type;
400  typedef returnT result_type;
401  typedef arg1T arg1_type;
402  typedef arg2T arg2_type;
403  typedef arg3T arg3_type;
404  typedef arg4T arg4_type;
405  typedef arg5T arg5_type;
406  typedef arg6T arg6_type;
407  typedef arg7T arg7_type;
408  };
409 
410 
411 
413  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T>
414  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T) const> {
415  static const bool value = true;
416  static const int arity = 8;
417  static const bool constness = true;
418  typedef objT obj_type;
419  typedef returnT result_type;
420  typedef arg1T arg1_type;
421  typedef arg2T arg2_type;
422  typedef arg3T arg3_type;
423  typedef arg4T arg4_type;
424  typedef arg5T arg5_type;
425  typedef arg6T arg6_type;
426  typedef arg7T arg7_type;
427  typedef arg8T arg8_type;
428  };
429 
430 
432  template <typename objT, typename returnT, typename arg1T, typename arg2T, typename arg3T, typename arg4T, typename arg5T, typename arg6T, typename arg7T, typename arg8T, typename arg9T>
433  struct memfunc_traits<returnT(objT::*)(arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T,arg9T) const> {
434  static const bool value = true;
435  static const int arity = 9;
436  static const bool constness = true;
437  typedef objT obj_type;
438  typedef returnT result_type;
439  typedef arg1T arg1_type;
440  typedef arg2T arg2_type;
441  typedef arg3T arg3_type;
442  typedef arg4T arg4_type;
443  typedef arg5T arg5_type;
444  typedef arg6T arg6_type;
445  typedef arg7T arg7_type;
446  typedef arg8T arg8_type;
447  typedef arg9T arg9_type;
448  };
449 
450  template <typename fnT, typename Enabler = void>
451  struct result_of {
452  typedef typename fnT::result_type type;
453  };
454 
455  template <typename fnT>
456  struct result_of<fnT, typename enable_if_c<function_traits<fnT>::value>::type> {
458  };
459 
460  template <typename fnT>
461  struct result_of<fnT, typename enable_if_c<memfunc_traits<fnT>::value>::type> {
463  };
464  }
465 }
466  namespace detail {
467  using namespace ::madness::tr1::detail;
468  }
469 }
470 #endif
Definition: function_traits_bits.h:451
returnT result_type
Definition: function_traits_bits.h:163
Function traits in the spirt of boost function traits.
Definition: function_traits_bits.h:10
returnT result_type
Definition: function_traits_bits.h:25
returnT result_type
Definition: function_traits_bits.h:17
arg1T arg1_type
Definition: function_traits_bits.h:164
bool_constant< false > false_type
Definition: gtest-port.h:1617
memfunc_traits< fnT >::result_type type
Definition: function_traits_bits.h:462
arg2T arg2_type
Definition: function_traits_bits.h:36
Member function traits in the spirt of boost function traits.
Definition: function_traits_bits.h:142
returnT result_type
Definition: function_traits_bits.h:314
static const bool value
Definition: function_traits_bits.h:143
returnT result_type
Definition: function_traits_bits.h:34
objT obj_type
Definition: function_traits_bits.h:152
returnT result_type
Definition: function_traits_bits.h:44
enable_if_c from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:46
objT obj_type
Definition: function_traits_bits.h:303
arg1T arg1_type
Definition: function_traits_bits.h:35
Definition: function_traits_bits.h:7
fnT::result_type type
Definition: function_traits_bits.h:452
returnT result_type
Definition: function_traits_bits.h:174
function_traits< fnT >::result_type type
Definition: function_traits_bits.h:457
returnT result_type
Definition: function_traits_bits.h:153
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
objT obj_type
Definition: function_traits_bits.h:162
returnT result_type
Definition: function_traits_bits.h:304
arg1T arg1_type
Definition: function_traits_bits.h:26