libsigc++ 2.5.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

Classes
Slots
Functors

Slots are type-safe representations of callback methods and functions. More...

## Classes

struct | sigc::nil
| nil struct type. More...
class | sigc::slot< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 >
| Convenience wrapper for the numbered sigc::slot# templates. More...
class | sigc::slot0< T_return >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot1< T_return, T_arg1 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot2< T_return, T_arg1, T_arg2 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot3< T_return, T_arg1, T_arg2, T_arg3 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot4< T_return, T_arg1, T_arg2, T_arg3, T_arg4 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot5< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot6< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot7< T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7 >
| Converts an arbitrary functor to a unified type which is opaque. More...
class | sigc::slot_base
| Base type for slots. More...

## Detailed Description

Slots are type-safe representations of callback methods and functions.

A Slot can be constructed from any function object or function, regardless of whether it is a global function, a member method, static, or virtual.

Use the sigc::mem_fun() and sigc::ptr_fun() template functions to get a sigc::slot, like so:

sigc::slot<void, int> sl = sigc::mem_fun(someobj, &SomeClass::somemethod);

or

sigc::slot<void, int> sl = sigc::ptr_fun(&somefunction);

or

m_Button.signal_clicked().connect( sigc::mem_fun(*this, &MyWindow::on_button_clicked) );

The compiler will complain if SomeClass::somemethod, etc. have the wrong signature.

You can also pass slots as method parameters where you might normally pass a function pointer.

A C++11 lambda expression is a functor (function object). It is automatically wrapped in a slot, if it is connected to a signal.

auto on_response = [&someobj] (int response_id)
{
someobj.somemethod(response_id);
somefunction(response_id);
};
m_Dialog.signal_response().connect(on_response);

If you connect a C++11 lambda expression or a std::function<> instance to a signal or assign it to a slot,

- With libsigc++ versions before 2.6, if the return type is not void, you must use the SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE macro,
- if your functor contains references to sigc::trackable derived objects, those objects will not be tracked, unless you also use sigc::track_obj().