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