sigc::slot< T_return(T_arg...)> Class Template Reference
Functors » Slots

Converts an arbitrary functor to a unified type which is opaque. More...

`#include <sigc++/functors/slot.h>`

Inheritance diagram for sigc::slot< T_return(T_arg...)>:
[legend]

## Public Types

using | result_type = T_return
Public Types inherited from sigc::slot_base
typedef trackable::func_destroy_notify | func_destroy_notify

## Public Member Functions

| slot ()
template<class T_functor >
| slot (const T_functor& _A_func)
| Constructs a slot from an arbitrary functor. More...
| slot (const slot& src)
| Constructs a slot, copying an existing one. More...
| slot (slot&& src)
| Constructs a slot, moving an existing one. More...
T_return | operator() (type_trait_take_t< T_arg >..._A_a) const
| Invoke the contained functor unless slot is in blocking state. More...
slot& | operator= (const slot& src)
| Overrides this slot, making a copy from another slot. More...
slot& | operator= (slot&& src)
| Overrides this slot, making a move from another slot. More...
Public Member Functions inherited from sigc::slot_base
| slot_base () noexcept
| Constructs an empty slot. More...
| slot_base (rep_type* rep) noexcept
| Constructs a slot from an existing slot_rep object. More...
| slot_base (const slot_base& src)
| Constructs a slot, copying an existing one. More...
| slot_base (slot_base&& src)
| Constructs a slot, moving an existing one. More...
| ~slot_base ()
void | add_destroy_notify_callback (void* data, func_destroy_notify func) const
| Add a callback that is executed (notified) when the slot is detroyed. More...
bool | block (bool should_block=true) noexcept
| Sets the blocking state. More...
bool | blocked () const noexcept
| Returns whether the slot is blocked. More...
void | disconnect ()
| Disconnects the slot. More...
bool | empty () const noexcept
| Returns whether the slot is invalid. More...
| operator bool () const noexcept
| Tests whether a slot is null, because the default constructor was used. More...
slot_base& | operator= (const slot_base& src)
| Overrides this slot, making a copy from another slot. More...
slot_base& | operator= (slot_base&& src)
| Overrides this slot, making a move from another slot. More...
void | remove_destroy_notify_callback (void* data) const
| Remove a callback previously installed with add_destroy_notify_callback(). More...
void | set_parent (void* parent, void*(* cleanup)(void*)) const noexcept
| Sets the parent of this slot. More...
bool | unblock () noexcept
| Unsets the blocking state. More...

## Additional Inherited Members

Public Attributes inherited from sigc::slot_base
bool | blocked_
| Indicates whether the slot is blocked. More...
rep_type* | rep_
| Typed slot_rep object that contains a functor. More...

## Detailed Description

### template<class T_return, class... T_arg>
class sigc::slot< T_return(T_arg...)>

Converts an arbitrary functor to a unified type which is opaque.

sigc::slot itself is a functor or, to be more precise, a closure. It contains a single, arbitrary functor (or closure) that is executed in operator()().

The template arguments determine the function signature of operator()():

- T_return The return type of operator()().
- T_arg Argument types used in the definition of operator()().

For instance, to declare a slot that returns void and takes two parameters of bool and int:

sigc::slot<void(bool, int)> some_slot;

Alternatively, you may use this syntax:

sigc::slot<void, bool, int> some_slot;

To use, simply assign the desired functor to the slot. If the functor is not compatible with the parameter list defined with the template arguments then compiler errors are triggered. When called, the slot will invoke the functor with minimal copies. block() and unblock() can be used to block the functor's invocation from operator()() temporarily.

## Member Typedef Documentation

template <class T_return , class... T_arg>

using sigc::slot< T_return(T_arg...)>::result_type = T_return

## Constructor & Destructor Documentation

template <class T_return , class... T_arg>

sigc::slot< T_return(T_arg...)>::slot | ( |  | ) |

inline

template <class T_return , class... T_arg>
template <class T_functor >

sigc::slot< T_return(T_arg...)>::slot | ( | const T_functor & | _A_func | ) |

inline

Constructs a slot from an arbitrary functor.

Parameters

  _A_func | The desired functor the new slot should be assigned to.

template <class T_return , class... T_arg>

sigc::slot< T_return(T_arg...)>::slot | ( | const slot< T_return(T_arg...)>& | src | ) |

inline

Constructs a slot, copying an existing one.

Parameters

  src | The existing slot to copy.

template <class T_return , class... T_arg>

sigc::slot< T_return(T_arg...)>::slot | ( | slot< T_return(T_arg...)>&& | src | ) |

inline

Constructs a slot, moving an existing one.

If `src` is connected to a parent (e.g. a signal), it is copied, not moved.

Parameters

  src | The existing slot to move or copy.

## Member Function Documentation

template <class T_return , class... T_arg>

T_return sigc::slot< T_return(T_arg...)>::operator() | ( | type_trait_take_t< T_arg >... | _A_a | ) | const

inline

Invoke the contained functor unless slot is in blocking state.

Parameters

  _A_a | Arguments to be passed on to the functor.

Returns
  The return value of the functor invocation.

template <class T_return , class... T_arg>

slot& sigc::slot< T_return(T_arg...)>::operator= | ( | const slot< T_return(T_arg...)>& | src | ) |

inline

Overrides this slot, making a copy from another slot.

Parameters

  src | The slot from which to make a copy.

Returns
  `this`.

template <class T_return , class... T_arg>

slot& sigc::slot< T_return(T_arg...)>::operator= | ( | slot< T_return(T_arg...)>&& | src | ) |

inline

Overrides this slot, making a move from another slot.

If `src` is connected to a parent (e.g. a signal), it is copied, not moved.

Parameters

  src | The slot from which to move or copy.

Returns
  `this`.