1
dnl Copyright 2002, The libsigc++ Development Team
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.
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.
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
18
include(template.macros.m4)
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
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; };
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)>
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;
46
#include <sigc++/functors/functor_trait.h>
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.
57
* adaptor_base inherits from the functor_base hint so
58
* derived types should also have a result_type defined.
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
67
struct adaptor_base : public functor_base {};
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
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.
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.
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; };
94
FOR(0,CALL_SIZE,[[DEDUCE_RESULT_TYPE_ADAPTOR(%1,CALL_SIZE)]])dnl
96
dnl #ifdef SIGC_CXX_TYPEOF
97
dnl FOR(0,CALL_SIZE,[[DEDUCE_RESULT_TYPE_TYPEOF(%1,CALL_SIZE)]])
100
} /* namespace sigc */