~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/sigc++2/sigc++/adaptors/macros/deduce_result_type.h.m4

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl Copyright 2002, The libsigc++ Development Team 
 
2
dnl 
 
3
dnl This library is free software; you can redistribute it and/or 
 
4
dnl modify it under the terms of the GNU Lesser General Public 
 
5
dnl License as published by the Free Software Foundation; either 
 
6
dnl version 2.1 of the License, or (at your option) any later version. 
 
7
dnl 
 
8
dnl This library is distributed in the hope that it will be useful, 
 
9
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 
 
10
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 
11
dnl Lesser General Public License for more details. 
 
12
dnl 
 
13
dnl You should have received a copy of the GNU Lesser General Public 
 
14
dnl License along with this library; if not, write to the Free Software 
 
15
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 
16
dnl
 
17
divert(-1)
 
18
include(template.macros.m4)
 
19
 
 
20
define([DEDUCE_RESULT_TYPE_ADAPTOR],[dnl
 
21
/** Deduce the return type of a functor.
 
22
 * This is the template specialization of the sigc::deduce_result_type template
 
23
 * for $1 arguments.
 
24
 */
 
25
template <LIST(class T_functor, LOOP(class T_arg%1, $1))>
 
26
struct deduce_result_type<LIST(T_functor, LOOP(T_arg%1,$1), LOOP(void,eval($2-$1)), true)>
 
27
  { typedef typename T_functor::template deduce_result_type<LOOP(T_arg%1,$1)>::type type; };
 
28
 
 
29
])
 
30
dnl 01.11.2003: Completely removed support for typeof() since it is non-standard!
 
31
dnl define([DEDUCE_RESULT_TYPE_TYPEOF],[dnl
 
32
dnl template <LIST(class T_functor, LOOP(class T_arg%1, $1))>
 
33
dnl struct deduce_result_type<LIST(T_functor, LOOP(T_arg%1,$1), LOOP(void,eval($2-$1)), false)>
 
34
dnl {
 
35
dnl   typedef typeof(type_trait<T_functor>::instance().
 
36
dnl                    T_functor::operator()(LOOP([
 
37
dnl                       type_trait<T_arg%1>::instance()], $1))) type;
 
38
dnl };
 
39
dnl 
 
40
dnl ])
 
41
 
 
42
divert(0)dnl
 
43
/*
 
44
*/
 
45
__FIREWALL__
 
46
#include <sigc++/functors/functor_trait.h>
 
47
 
 
48
 
 
49
namespace sigc {
 
50
 
 
51
/** A hint to the compiler.
 
52
 * Functors which have all methods based on templates
 
53
 * should publicly inherit from this hint and define 
 
54
 * a nested template class @p deduce_result_type that
 
55
 * can be used to deduce the methods' return types.
 
56
 *
 
57
 * adaptor_base inherits from the functor_base hint so
 
58
 * derived types should also have a result_type defined.
 
59
 *
 
60
 * Adaptors don't inherit from this type directly. They use
 
61
 * use sigc::adapts as a base type instead. sigc::adaptors
 
62
 * wraps arbitrary functor types as well as function pointers
 
63
 * and class methods.
 
64
 *
 
65
 * @ingroup adaptors
 
66
 */
 
67
struct adaptor_base : public functor_base {};
 
68
 
 
69
 
 
70
/** Deduce the return type of a functor.
 
71
 * <tt>typename deduce_result_type<functor_type, [list of arg_types]>::type</tt>
 
72
 * deduces a functor's result type if @p functor_type inherits from
 
73
 * sigc::functor_base and defines @p result_type or if @p functor_type
 
74
 * is actually a (member) function type. Multi-type functors are not
 
75
 * supported.
 
76
 *
 
77
 * sigc++ adaptors use
 
78
 * <tt>typename deduce_result_type<functor_type, [list of arg_types]>::type</tt>
 
79
 * to determine the return type of their <tt>templated operator()</tt> overloads.
 
80
 *
 
81
 * Adaptors in turn define a nested template class @p deduce_result_type
 
82
 * that is used by template specializations of the global deduce_result_type
 
83
 * template to correctly deduce the return types of the adaptor's suitable
 
84
 * <tt>template operator()</tt> overload.
 
85
 *
 
86
 * @ingroup adaptors
 
87
 */
 
88
template <class T_functor,
 
89
          LOOP(class T_arg%1=void, CALL_SIZE),
 
90
          bool I_derives_adaptor_base=is_base_and_derived<adaptor_base,T_functor>::value>
 
91
struct deduce_result_type
 
92
  { typedef typename functor_trait<T_functor>::result_type type; };
 
93
 
 
94
FOR(0,CALL_SIZE,[[DEDUCE_RESULT_TYPE_ADAPTOR(%1,CALL_SIZE)]])dnl
 
95
 
 
96
dnl #ifdef SIGC_CXX_TYPEOF
 
97
dnl FOR(0,CALL_SIZE,[[DEDUCE_RESULT_TYPE_TYPEOF(%1,CALL_SIZE)]])
 
98
dnl #endif
 
99
dnl
 
100
} /* namespace sigc */