Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template signal

boost::signals2::signal — Safe multicast callback.


// In header: <boost/signals2/signal.hpp>

template<typename Signature,   // Function type R (T1, T2, ..., TN)
         typename Combiner = optional_last_value<R>, 
         typename Group = int, 
         typename GroupCompare = std::less<Group>, 
         typename SlotFunction = function<Signature>, 
         typename ExtendedSlotFunction = function<R (const connection &, T1, T2, ..., TN)>, 
         typename Mutex = mutex> 
class signal : public signalN<R, T1, T2, ..., TN, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>
  // types
  typedef Signature signature_type;

  // construct/copy/destruct
  signal(const combiner_type& = combiner_type(), 
         const group_compare_type& = group_compare_type());


Class template signal is a thin wrapper around the numbered class templates signal0, signal1, etc. It accepts a function type with N arguments instead of N separate arguments, and derives from the appropriate signalN instantiation.

All functionality of this class template is in its base class signalN.

The large number of template parameters for the signal class can be an inconvenience. The the signal_type metafunction is provided to overcome this problem. It uses the Boost.Parameter library to permit specification of the signal class' template type parameters as named parameters.

signal public construct/copy/destruct

  1. signal(const combiner_type& combiner = combiner_type(), 
           const group_compare_type& compare = group_compare_type());


    Initializes the base class with the given combiner and comparison objects.