Chris@16
|
1 // -- select_functions.hpp -- Boost Lambda Library --------------------------
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
6 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see http://www.boost.org
|
Chris@16
|
10
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_LAMBDA_SELECT_FUNCTIONS_HPP
|
Chris@16
|
13 #define BOOST_LAMBDA_SELECT_FUNCTIONS_HPP
|
Chris@16
|
14
|
Chris@16
|
15 namespace boost {
|
Chris@16
|
16 namespace lambda {
|
Chris@16
|
17 namespace detail {
|
Chris@16
|
18
|
Chris@16
|
19
|
Chris@16
|
20 // select functions -------------------------------
|
Chris@16
|
21 template<class Any, CALL_TEMPLATE_ARGS>
|
Chris@16
|
22 inline Any& select(Any& any, CALL_FORMAL_ARGS) { CALL_USE_ARGS; return any; }
|
Chris@16
|
23
|
Chris@16
|
24
|
Chris@16
|
25 template<class Arg, CALL_TEMPLATE_ARGS>
|
Chris@16
|
26 inline typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
|
Chris@16
|
27 select ( const lambda_functor<Arg>& op, CALL_FORMAL_ARGS ) {
|
Chris@16
|
28 return op.template call<
|
Chris@16
|
29 typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
|
Chris@16
|
30 >(CALL_ACTUAL_ARGS);
|
Chris@16
|
31 }
|
Chris@16
|
32 template<class Arg, CALL_TEMPLATE_ARGS>
|
Chris@16
|
33 inline typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
|
Chris@16
|
34 select ( lambda_functor<Arg>& op, CALL_FORMAL_ARGS) {
|
Chris@16
|
35 return op.template call<
|
Chris@16
|
36 typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
|
Chris@16
|
37 >(CALL_ACTUAL_ARGS);
|
Chris@16
|
38 }
|
Chris@16
|
39
|
Chris@16
|
40 // ------------------------------------------------------------------------
|
Chris@16
|
41 // select functions where the return type is explicitly given
|
Chris@16
|
42 // Note: on many functions, this return type is just discarded.
|
Chris@16
|
43 // The select functions are inside a class template, and the return type
|
Chris@16
|
44 // is a class template argument.
|
Chris@16
|
45 // The first implementation used function templates with an explicitly
|
Chris@16
|
46 // specified template parameter.
|
Chris@16
|
47 // However, this resulted in ambiguous calls (at least with gcc 2.95.2
|
Chris@16
|
48 // and edg 2.44). Not sure whether the compilers were right or wrong.
|
Chris@16
|
49
|
Chris@16
|
50 template<class RET> struct r_select {
|
Chris@16
|
51
|
Chris@16
|
52 // Any == RET
|
Chris@16
|
53 template<class Any, CALL_TEMPLATE_ARGS>
|
Chris@16
|
54 static
|
Chris@16
|
55 inline RET go (Any& any, CALL_FORMAL_ARGS) { CALL_USE_ARGS; return any; }
|
Chris@16
|
56
|
Chris@16
|
57
|
Chris@16
|
58 template<class Arg, CALL_TEMPLATE_ARGS>
|
Chris@16
|
59 static
|
Chris@16
|
60 inline RET go (const lambda_functor<Arg>& op, CALL_FORMAL_ARGS ) {
|
Chris@16
|
61 return op.template call<RET>(CALL_ACTUAL_ARGS);
|
Chris@16
|
62 }
|
Chris@16
|
63 template<class Arg, CALL_TEMPLATE_ARGS>
|
Chris@16
|
64 static
|
Chris@16
|
65 inline RET go (lambda_functor<Arg>& op, CALL_FORMAL_ARGS ) {
|
Chris@16
|
66 return op.template call<RET>(CALL_ACTUAL_ARGS);
|
Chris@16
|
67 }
|
Chris@16
|
68 };
|
Chris@16
|
69
|
Chris@16
|
70 } // namespace detail
|
Chris@16
|
71 } // namespace lambda
|
Chris@16
|
72 } // namespace boost
|
Chris@16
|
73
|
Chris@16
|
74 #endif
|