annotate DEPENDENCIES/generic/include/boost/signals2/detail/signals_common.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost.Signals library
Chris@16 2
Chris@16 3 // Copyright Douglas Gregor 2001-2004.
Chris@16 4 // Copyright Frank Mori Hess 2007. Use, modification and
Chris@16 5 // distribution is subject to the Boost Software License, Version
Chris@16 6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // For more information, see http://www.boost.org
Chris@16 10
Chris@16 11 #ifndef BOOST_SIGNALS2_SIGNALS_COMMON_HPP
Chris@16 12 #define BOOST_SIGNALS2_SIGNALS_COMMON_HPP
Chris@16 13
Chris@16 14 #include <boost/mpl/bool.hpp>
Chris@16 15 #include <boost/mpl/if.hpp>
Chris@16 16 #include <boost/ref.hpp>
Chris@16 17 #include <boost/signals2/signal_base.hpp>
Chris@16 18 #include <boost/type_traits/is_base_of.hpp>
Chris@16 19
Chris@16 20 namespace boost {
Chris@16 21 namespace signals2 {
Chris@16 22 namespace detail {
Chris@16 23 // Determine if the given type T is a signal
Chris@16 24 template<typename T>
Chris@16 25 class is_signal: public mpl::bool_<is_base_of<signal_base, T>::value>
Chris@16 26 {};
Chris@16 27
Chris@16 28 // A slot can be a signal, a reference to a function object, or a
Chris@16 29 // function object.
Chris@16 30 struct signal_tag {};
Chris@16 31 struct reference_tag {};
Chris@16 32 struct value_tag {};
Chris@16 33
Chris@16 34 // Classify the given slot as a signal, a reference-to-slot, or a
Chris@16 35 // standard slot
Chris@16 36 template<typename S>
Chris@16 37 class get_slot_tag {
Chris@16 38 typedef typename mpl::if_<is_signal<S>,
Chris@16 39 signal_tag, value_tag>::type signal_or_value;
Chris@16 40 public:
Chris@16 41 typedef typename mpl::if_<is_reference_wrapper<S>,
Chris@16 42 reference_tag,
Chris@16 43 signal_or_value>::type type;
Chris@16 44 };
Chris@16 45
Chris@16 46 // Get the slot so that it can be copied
Chris@16 47 template<typename F>
Chris@16 48 typename F::weak_signal_type
Chris@16 49 get_invocable_slot(const F &signal, signal_tag)
Chris@16 50 { return typename F::weak_signal_type(signal); }
Chris@16 51
Chris@16 52 template<typename F>
Chris@16 53 const F&
Chris@16 54 get_invocable_slot(const F& f, reference_tag)
Chris@16 55 { return f; }
Chris@16 56
Chris@16 57 template<typename F>
Chris@16 58 const F&
Chris@16 59 get_invocable_slot(const F& f, value_tag)
Chris@16 60 { return f; }
Chris@16 61
Chris@16 62 // Determines the type of the slot - is it a signal, a reference to a
Chris@16 63 // slot or just a normal slot.
Chris@16 64 template<typename F>
Chris@16 65 typename get_slot_tag<F>::type
Chris@16 66 tag_type(const F&)
Chris@16 67 {
Chris@16 68 typedef typename get_slot_tag<F>::type
Chris@16 69 the_tag_type;
Chris@16 70 the_tag_type tag = the_tag_type();
Chris@16 71 return tag;
Chris@16 72 }
Chris@16 73 } // end namespace detail
Chris@16 74 } // end namespace signals2
Chris@16 75 } // end namespace boost
Chris@16 76
Chris@16 77 #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP