]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/signals2/detail/signals_common.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / signals2 / detail / signals_common.hpp
1 // Boost.Signals library
2
3 // Copyright Douglas Gregor 2001-2004.
4 // Copyright Frank Mori Hess 2007. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See 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 #ifndef BOOST_SIGNALS2_SIGNALS_COMMON_HPP
12 #define BOOST_SIGNALS2_SIGNALS_COMMON_HPP
13
14 #include <boost/mpl/bool.hpp>
15 #include <boost/mpl/if.hpp>
16 #include <boost/ref.hpp>
17 #include <boost/signals2/signal_base.hpp>
18 #include <boost/type_traits/is_base_of.hpp>
19
20 namespace boost {
21 namespace signals2 {
22 namespace detail {
23 // Determine if the given type T is a signal
24 template<typename T>
25 class is_signal: public mpl::bool_<is_base_of<signal_base, T>::value>
26 {};
27
28 // A slot can be a signal, a reference to a function object, or a
29 // function object.
30 struct signal_tag {};
31 struct reference_tag {};
32 struct value_tag {};
33
34 // Classify the given slot as a signal, a reference-to-slot, or a
35 // standard slot
36 template<typename S>
37 class get_slot_tag {
38 typedef typename mpl::if_<is_signal<S>,
39 signal_tag, value_tag>::type signal_or_value;
40 public:
41 typedef typename mpl::if_<is_reference_wrapper<S>,
42 reference_tag,
43 signal_or_value>::type type;
44 };
45
46 // Get the slot so that it can be copied
47 template<typename F>
48 typename F::weak_signal_type
49 get_invocable_slot(const F &signal, signal_tag)
50 { return typename F::weak_signal_type(signal); }
51
52 template<typename F>
53 const F&
54 get_invocable_slot(const F& f, reference_tag)
55 { return f; }
56
57 template<typename F>
58 const F&
59 get_invocable_slot(const F& f, value_tag)
60 { return f; }
61
62 // Determines the type of the slot - is it a signal, a reference to a
63 // slot or just a normal slot.
64 template<typename F>
65 typename get_slot_tag<F>::type
66 tag_type(const F&)
67 {
68 typedef typename get_slot_tag<F>::type
69 the_tag_type;
70 the_tag_type tag = the_tag_type();
71 return tag;
72 }
73 } // end namespace detail
74 } // end namespace signals2
75 } // end namespace boost
76
77 #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP