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_type

boost::signals2::signal_type — Specify a the template type parameters of a boost::signals2::signal using named parameters.


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

template<typename A0, typename A1 = boost::parameter::void_, 
         typename A2 = boost::parameter::void_, 
         typename A3 = boost::parameter::void_, 
         typename A4 = boost::parameter::void_, 
         typename A5 = boost::parameter::void_, 
         typename A6 = boost::parameter::void_> 
class signal_type {
  // types
  typedef implementation-detail                                           signature_type;             
  typedef implementation-detail                                           combiner_type;              
  typedef implementation-detail                                           group_type;                 
  typedef implementation-detail                                           group_compare_type;         
  typedef implementation-detail                                           slot_function_type;         
  typedef implementation-detail                                           extended_slot_function_type;
  typedef implementation-detail                                           mutex_type;                 
  typedef typename signal<signature_type, combiner_type, ..., mutex_type> type;                       


The signal_type metafunction employs the Boost.Parameter library to allow users to specify the template type parameters of a signal using named parameters. The resulting signal type is provided through the signal_type::type typedef. Named template type parameters can enhance readability of code, and provide convenience for specifying classes which have a large number of template parameters.

The template type parameters may be passed positionally, similarly to passing them to the signal class directly. Or, they may be passed as named template parameters by wrapping them in one of the template keyword classes provided in the boost::signals2::keywords namespace. The supported template keywords are: keywords::signature_type, keywords::combiner_type, keywords::group_type, keywords::group_compare_type, keywords::slot_function_type, keywords::extended_slot_function_type, and keywords::mutex_type.

The default types for unspecified template type parameters are the same as those for the signal class.

Named template type parameters are especially convenient when you only wish to change a few of a signal's template type parameters from their defaults, and the parameters you wish to change are near the end of the signal's template parameter list. For example, if you only wish to change the Mutex template type parameter of a signal, you might write:

namespace bs2 = boost::signals2;
using bs2::keywords;
bs2::signal_type<void (), mutex_type<bs2::dummy_mutex> >::type sig;

For comparison, to specify the same type using the signal class directly looks like:

namespace bs2 = boost::signals2;
    void (),
    boost::function<void ()>,
    boost::function<void (const connection &)>,
  > sig;