| Home | Libraries | People | FAQ | More

## Class template signal_type

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

## Synopsis

    // 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 {
    public:
      // 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;
    };

## Description

The `signal_type` metafunction employs the Boost.Parameter library to allow users to specify the template type parameters of a signals2::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 signals2::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 namespace 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;
    bs2::signal
      <
        void (),
        bs2::optional_last_value<void>,
        int,
        std::less<int>,
        boost::function<void ()>,
        boost::function<void (const connection &)>,
        bs2::dummy_mutex
      > sig;