1 // Boost.Signals library
3 // Copyright Douglas Gregor 2001-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
10 #ifndef BOOST_SIGNALS_COMMON_HEADER
11 #define BOOST_SIGNALS_COMMON_HEADER
13 #ifndef BOOST_SIGNALS_NAMESPACE
14 # define BOOST_SIGNALS_NAMESPACE signals
17 #include <boost/type_traits/conversion_traits.hpp>
18 #include <boost/ref.hpp>
19 #include <boost/signals/detail/config.hpp>
21 #ifdef BOOST_HAS_ABI_HEADERS
22 # include BOOST_ABI_PREFIX
26 namespace BOOST_SIGNALS_NAMESPACE {
28 // The unusable class is a placeholder for unused function arguments
29 // It is also completely unusable except that it constructable from
30 // anything. This helps compilers without partial specialization
31 // handle slots returning void.
36 // Determine the result type of a slot call
38 struct slot_result_type {
43 struct slot_result_type<void> {
44 typedef unusable type;
47 // Determine if the given type T is a signal
52 BOOST_STATIC_CONSTANT(bool,
53 value = (is_convertible<T*, signal_base*>::value));
57 * The IF implementation is temporary code. When a Boost metaprogramming
58 * library is introduced, Boost.Signals will use it instead.
63 template<typename Then, typename Else>
72 template<typename Then, typename Else>
79 template<bool Condition>
82 typedef SelectThen type;
86 struct Selector<false>
88 typedef SelectElse type;
90 } // end namespace intimate
92 template<bool Condition, typename Then, typename Else>
95 typedef typename intimate::Selector<Condition>::type select;
96 typedef typename select::template Result<Then,Else>::type type;
99 // Determine if the incoming argument is a reference_wrapper
100 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
104 BOOST_STATIC_CONSTANT(bool, value = false);
108 struct is_ref<reference_wrapper<T> >
110 BOOST_STATIC_CONSTANT(bool, value = true);
112 #else // no partial specialization
113 typedef char yes_type;
114 typedef double no_type;
116 no_type is_ref_tester(...);
119 yes_type is_ref_tester(reference_wrapper<T>*);
125 BOOST_STATIC_CONSTANT(bool,
126 value = (sizeof(is_ref_tester(t)) == sizeof(yes_type)));
128 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
130 // A slot can be a signal, a reference to a function object, or a
132 struct signal_tag {};
133 struct reference_tag {};
136 // Classify the given slot as a signal, a reference-to-slot, or a
140 typedef typename IF<(is_signal<S>::value),
142 value_tag>::type signal_or_value;
145 typedef typename IF<(is_ref<S>::value),
147 signal_or_value>::type type;
150 // Forward declaration needed in lots of places
151 class signal_base_impl;
152 class bound_objects_visitor;
154 } // end namespace detail
155 } // end namespace BOOST_SIGNALS_NAMESPACE
156 } // end namespace boost
158 #ifdef BOOST_HAS_ABI_HEADERS
159 # include BOOST_ABI_SUFFIX
162 #endif // BOOST_SIGNALS_COMMON_HEADER