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