source: NonGTP/Boost/boost/lambda/detail/select_functions.hpp @ 857

Revision 857, 2.4 KB checked in by igarcia, 19 years ago (diff)
Line 
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
15namespace boost {
16namespace lambda {
17namespace detail {
18
19
20// select functions -------------------------------
21template<class Any, CALL_TEMPLATE_ARGS>
22inline Any& select(Any& any, CALL_FORMAL_ARGS) { CALL_USE_ARGS; return any; }
23
24
25template<class Arg, CALL_TEMPLATE_ARGS>
26inline typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
27select ( 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}
32template<class Arg, CALL_TEMPLATE_ARGS>
33inline typename Arg::template sig<tuple<CALL_REFERENCE_TYPES> >::type
34select ( 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 
50template<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
Note: See TracBrowser for help on using the repository browser.