LCOV - code coverage report
Current view: top level - opt/homebrew/include/boost/signals2/detail - signals_common.hpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 7 7 100.0 %
Date: 2026-06-25 07:23:51 Functions: 10 36 27.8 %

          Line data    Source code
       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/core/ref.hpp>
      15             : #include <boost/mpl/bool.hpp>
      16             : #include <boost/mpl/if.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          28 :       get_invocable_slot(const F &signal, signal_tag)
      50          28 :       { 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         684 :       get_invocable_slot(const F& f, value_tag)
      60         684 :       { 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         712 :       tag_type(const F&)
      67             :       {
      68             :         typedef typename get_slot_tag<F>::type
      69             :           the_tag_type;
      70         712 :         the_tag_type tag = the_tag_type();
      71         712 :         return tag;
      72             :       }
      73             :     } // end namespace detail
      74             :   } // end namespace signals2
      75             : } // end namespace boost
      76             : 
      77             : #endif // BOOST_SIGNALS2_SIGNALS_COMMON_HPP

Generated by: LCOV version 1.16