fix doc example typo
[boost.git] / boost / signals2 / signal_type.hpp
blob4de5396fe20d271417fa79fbca013c37028912e8
1 /*
2 A meta function which supports using named template type parameters
3 via Boost.Parameter to specify the template type parameters for
4 the boost::signals2::signal class.
6 Author: Frank Mori Hess <fmhess@users.sourceforge.net>
7 Begin: 2009-01-22
8 */
9 // Copyright Frank Mori Hess 2009
10 // Use, modification and
11 // distribution is subject to the Boost Software License, Version
12 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 // For more information, see http://www.boost.org
17 #ifndef BOOST_SIGNALS2_SIGNAL_TYPE_HPP
18 #define BOOST_SIGNALS2_SIGNAL_TYPE_HPP
20 // support for function types is currently broken in Boost.Parameter
21 // #define BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
23 #include <boost/signals2/signal.hpp>
25 #if !defined(BOOST_PARAMETER_MAX_ARITY)
26 #define BOOST_PARAMETER_MAX_ARITY 7
27 #else
28 #if BOOST_PARAMETER_MAX_ARITY < 7
29 #error This header requires BOOST_PARAMETER_MAX_ARITY to be defined as 7 or greater prior to including Boost.Parameter headers
30 #endif // BOOST_PARAMETER_MAX_ARITY < 7
31 #endif // !defined(BOOST_PARAMETER_MAX_ARITY)
32 #include <boost/parameter.hpp>
34 #include <boost/type_traits/is_function.hpp>
36 namespace boost
38 namespace signals2
40 namespace keywords
42 #ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
43 BOOST_PARAMETER_TEMPLATE_KEYWORD(signature_type)
44 #endif
45 BOOST_PARAMETER_TEMPLATE_KEYWORD(combiner_type)
46 BOOST_PARAMETER_TEMPLATE_KEYWORD(group_type)
47 BOOST_PARAMETER_TEMPLATE_KEYWORD(group_compare_type)
48 BOOST_PARAMETER_TEMPLATE_KEYWORD(slot_function_type)
49 BOOST_PARAMETER_TEMPLATE_KEYWORD(extended_slot_function_type)
50 BOOST_PARAMETER_TEMPLATE_KEYWORD(mutex_type)
51 } // namespace keywords
53 template <
54 #ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
55 typename A0,
56 #else
57 typename Signature,
58 #endif
59 typename A1 = parameter::void_,
60 typename A2 = parameter::void_,
61 typename A3 = parameter::void_,
62 typename A4 = parameter::void_,
63 typename A5 = parameter::void_,
64 typename A6 = parameter::void_
66 class signal_type
68 typedef parameter::parameters<
69 #ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
70 parameter::required<keywords::tag::signature_type, is_function<boost::mpl::_> >,
71 #endif
72 parameter::optional<keywords::tag::combiner_type>,
73 parameter::optional<keywords::tag::group_type>,
74 parameter::optional<keywords::tag::group_compare_type>,
75 parameter::optional<keywords::tag::slot_function_type>,
76 parameter::optional<keywords::tag::extended_slot_function_type>,
77 parameter::optional<keywords::tag::mutex_type>
78 > parameter_spec;
80 public:
81 // ArgumentPack
82 typedef typename
83 parameter_spec::bind<
84 #ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
85 A0,
86 #endif
87 A1, A2, A3, A4, A5, A6>::type
88 args;
90 #ifdef BOOST_SIGNALS2_NAMED_SIGNATURE_PARAMETER
91 typedef typename parameter::value_type<args, keywords::tag::signature_type>::type
92 signature_type;
93 #else
94 typedef Signature signature_type;
95 #endif
97 typedef typename parameter::value_type
99 args,
100 keywords::tag::combiner_type,
101 optional_last_value
103 typename boost::function_traits<signature_type>::result_type
105 >::type combiner_type;
107 typedef typename
108 parameter::value_type<args, keywords::tag::group_type, int>::type group_type;
110 typedef typename
111 parameter::value_type<args, keywords::tag::group_compare_type, std::less<group_type> >::type
112 group_compare_type;
114 typedef typename
115 parameter::value_type<args, keywords::tag::slot_function_type, function<signature_type> >::type
116 slot_function_type;
118 typedef typename
119 parameter::value_type
121 args,
122 keywords::tag::extended_slot_function_type,
123 typename detail::extended_signature<function_traits<signature_type>::arity, signature_type>::function_type
124 >::type
125 extended_slot_function_type;
127 typedef typename
128 parameter::value_type<args, keywords::tag::mutex_type, mutex>::type mutex_type;
130 typedef signal
132 signature_type,
133 combiner_type,
134 group_type,
135 group_compare_type,
136 slot_function_type,
137 extended_slot_function_type,
138 mutex_type
139 > type;
141 } // namespace signals2
142 } // namespace boost
144 #endif // BOOST_SIGNALS2_SIGNAL_TYPE_HPP