2 /* Do not edit! -- generated file */
3 #ifndef _SIGC_FUNCTORS_SLOT_H_
4 #define _SIGC_FUNCTORS_SLOT_H_
5 #include <sigc++/trackable.h>
6 #include <sigc++/visit_each.h>
7 #include <sigc++/adaptors/adaptor_trait.h>
8 #include <sigc++/functors/slot_base.h>
10 //TODO: See comment in functor_trait.h.
11 #if defined(nil) && defined(SIGC_PRAGMA_PUSH_POP_MACRO)
12 #define SIGC_NIL_HAS_BEEN_PUSHED 1
13 #pragma push_macro("nil")
21 // Conversion between different types of function pointers with
22 // reinterpret_cast can make gcc8 print a warning.
23 // https://github.com/libsigcplusplus/libsigcplusplus/issues/1
24 // https://github.com/libsigcplusplus/libsigcplusplus/issues/8
25 /** Returns the supplied function pointer, cast to a pointer to another function type.
27 * When a single reinterpret_cast between function pointer types causes a
28 * compiler warning or error, this function may work.
30 * Qualify calls with namespace names: sigc::internal::function_pointer_cast<>().
31 * If you don't, indirect calls from another library that also contains a
32 * function_pointer_cast<>() (perhaps glibmm), can be ambiguous due to ADL
33 * (argument-dependent lookup).
35 template <typename T_out, typename T_in>
36 inline T_out function_pointer_cast(T_in in)
38 // The double reinterpret_cast suppresses a warning from gcc8 with the
39 // -Wcast-function-type option.
40 return reinterpret_cast<T_out>(reinterpret_cast<void (*)()>(in));
44 * A typed slot_rep holds a functor that can be invoked from
45 * slot::operator()(). visit_each() is used to visit the functor's
46 * targets that inherit trackable recursively and register the
47 * notification callback. Consequently the slot_rep object will be
48 * notified when some referred object is destroyed or overwritten.
50 template <class T_functor>
51 struct typed_slot_rep : public slot_rep
53 typedef typed_slot_rep<T_functor> self;
55 /* Use an adaptor type so that arguments can be passed as const references
56 * through explicit template instantiation from slot_call#::call_it() */
57 typedef typename adaptor_trait<T_functor>::adaptor_type adaptor_type;
59 /** The functor contained by this slot_rep object. */
60 adaptor_type functor_;
62 /** Constructs an invalid typed slot_rep object.
63 * The notification callback is registered using visit_each().
64 * @param functor The functor contained by the new slot_rep object.
66 inline typed_slot_rep(const T_functor& functor)
67 : slot_rep(nullptr, &destroy, &dup), functor_(functor)
68 { sigc::visit_each_type<trackable*>(slot_do_bind(this), functor_); }
70 inline typed_slot_rep(const typed_slot_rep& cl)
71 : slot_rep(cl.call_, &destroy, &dup), functor_(cl.functor_)
72 { sigc::visit_each_type<trackable*>(slot_do_bind(this), functor_); }
74 typed_slot_rep& operator=(const typed_slot_rep& src) = delete;
76 typed_slot_rep(typed_slot_rep&& src) = delete;
77 typed_slot_rep& operator=(typed_slot_rep&& src) = delete;
79 inline ~typed_slot_rep()
83 sigc::visit_each_type<trackable*>(slot_do_unbind(this), functor_);
86 /** Detaches the stored functor from the other referred trackables and destroys it.
87 * This does not destroy the base slot_rep object.
89 static void* destroy(void* data)
91 self* self_ = static_cast<self*>(reinterpret_cast<slot_rep*>(data));
92 self_->call_ = nullptr;
93 self_->destroy_ = nullptr;
94 sigc::visit_each_type<trackable*>(slot_do_unbind(self_), self_->functor_);
95 self_->functor_.~adaptor_type();
96 /* don't call disconnect() here: destroy() is either called
97 * a) from the parent itself (in which case disconnect() leads to a segfault) or
98 * b) from a parentless slot (in which case disconnect() does nothing)
103 /** Makes a deep copy of the slot_rep object.
104 * Deep copy means that the notification callback of the new
105 * slot_rep object is registered in the referred trackables.
106 * @return A deep copy of the slot_rep object.
108 static void* dup(void* data)
110 slot_rep* a_rep = reinterpret_cast<slot_rep*>(data);
111 return static_cast<slot_rep*>(new self(*static_cast<self*>(a_rep)));
115 /** Abstracts functor execution.
116 * call_it() invokes a functor of type @e T_functor with a list of
117 * parameters whose types are given by the template arguments.
118 * address() forms a function pointer from call_it().
120 * The following template arguments are used:
121 * - @e T_functor The functor type.
122 * - @e T_return The return type of call_it().
125 template<class T_functor, class T_return>
128 /** Invokes a functor of type @p T_functor.
129 * @param rep slot_rep object that holds a functor of type @p T_functor.
130 * @return The return values of the functor invocation.
132 static T_return call_it(slot_rep* rep)
134 typedef typed_slot_rep<T_functor> typed_slot;
135 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
136 return (typed_rep->functor_)();
139 /** Forms a function pointer from call_it().
140 * @return A function pointer formed from call_it().
142 static hook address()
143 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
146 /** Abstracts functor execution.
147 * call_it() invokes a functor of type @e T_functor with a list of
148 * parameters whose types are given by the template arguments.
149 * address() forms a function pointer from call_it().
151 * The following template arguments are used:
152 * - @e T_functor The functor type.
153 * - @e T_return The return type of call_it().
154 * - @e T_arg1 Argument type used in the definition of call_it().
157 template<class T_functor, class T_return, class T_arg1>
160 /** Invokes a functor of type @p T_functor.
161 * @param rep slot_rep object that holds a functor of type @p T_functor.
162 * @param _A_a1 Argument to be passed on to the functor.
163 * @return The return values of the functor invocation.
165 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1)
167 typedef typed_slot_rep<T_functor> typed_slot;
168 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
169 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>>
173 /** Forms a function pointer from call_it().
174 * @return A function pointer formed from call_it().
176 static hook address()
177 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
180 /** Abstracts functor execution.
181 * call_it() invokes a functor of type @e T_functor with a list of
182 * parameters whose types are given by the template arguments.
183 * address() forms a function pointer from call_it().
185 * The following template arguments are used:
186 * - @e T_functor The functor type.
187 * - @e T_return The return type of call_it().
188 * - @e T_arg1 Argument type used in the definition of call_it().
189 * - @e T_arg2 Argument type used in the definition of call_it().
192 template<class T_functor, class T_return, class T_arg1, class T_arg2>
195 /** Invokes a functor of type @p T_functor.
196 * @param rep slot_rep object that holds a functor of type @p T_functor.
197 * @param _A_a1 Argument to be passed on to the functor.
198 * @param _A_a2 Argument to be passed on to the functor.
199 * @return The return values of the functor invocation.
201 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2)
203 typedef typed_slot_rep<T_functor> typed_slot;
204 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
205 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>>
209 /** Forms a function pointer from call_it().
210 * @return A function pointer formed from call_it().
212 static hook address()
213 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
216 /** Abstracts functor execution.
217 * call_it() invokes a functor of type @e T_functor with a list of
218 * parameters whose types are given by the template arguments.
219 * address() forms a function pointer from call_it().
221 * The following template arguments are used:
222 * - @e T_functor The functor type.
223 * - @e T_return The return type of call_it().
224 * - @e T_arg1 Argument type used in the definition of call_it().
225 * - @e T_arg2 Argument type used in the definition of call_it().
226 * - @e T_arg3 Argument type used in the definition of call_it().
229 template<class T_functor, class T_return, class T_arg1, class T_arg2, class T_arg3>
232 /** Invokes a functor of type @p T_functor.
233 * @param rep slot_rep object that holds a functor of type @p T_functor.
234 * @param _A_a1 Argument to be passed on to the functor.
235 * @param _A_a2 Argument to be passed on to the functor.
236 * @param _A_a3 Argument to be passed on to the functor.
237 * @return The return values of the functor invocation.
239 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2, type_trait_take_t<T_arg3> a_3)
241 typedef typed_slot_rep<T_functor> typed_slot;
242 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
243 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>, type_trait_take_t<T_arg3>>
247 /** Forms a function pointer from call_it().
248 * @return A function pointer formed from call_it().
250 static hook address()
251 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
254 /** Abstracts functor execution.
255 * call_it() invokes a functor of type @e T_functor with a list of
256 * parameters whose types are given by the template arguments.
257 * address() forms a function pointer from call_it().
259 * The following template arguments are used:
260 * - @e T_functor The functor type.
261 * - @e T_return The return type of call_it().
262 * - @e T_arg1 Argument type used in the definition of call_it().
263 * - @e T_arg2 Argument type used in the definition of call_it().
264 * - @e T_arg3 Argument type used in the definition of call_it().
265 * - @e T_arg4 Argument type used in the definition of call_it().
268 template<class T_functor, class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4>
271 /** Invokes a functor of type @p T_functor.
272 * @param rep slot_rep object that holds a functor of type @p T_functor.
273 * @param _A_a1 Argument to be passed on to the functor.
274 * @param _A_a2 Argument to be passed on to the functor.
275 * @param _A_a3 Argument to be passed on to the functor.
276 * @param _A_a4 Argument to be passed on to the functor.
277 * @return The return values of the functor invocation.
279 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2, type_trait_take_t<T_arg3> a_3, type_trait_take_t<T_arg4> a_4)
281 typedef typed_slot_rep<T_functor> typed_slot;
282 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
283 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>, type_trait_take_t<T_arg3>, type_trait_take_t<T_arg4>>
284 (a_1, a_2, a_3, a_4);
287 /** Forms a function pointer from call_it().
288 * @return A function pointer formed from call_it().
290 static hook address()
291 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
294 /** Abstracts functor execution.
295 * call_it() invokes a functor of type @e T_functor with a list of
296 * parameters whose types are given by the template arguments.
297 * address() forms a function pointer from call_it().
299 * The following template arguments are used:
300 * - @e T_functor The functor type.
301 * - @e T_return The return type of call_it().
302 * - @e T_arg1 Argument type used in the definition of call_it().
303 * - @e T_arg2 Argument type used in the definition of call_it().
304 * - @e T_arg3 Argument type used in the definition of call_it().
305 * - @e T_arg4 Argument type used in the definition of call_it().
306 * - @e T_arg5 Argument type used in the definition of call_it().
309 template<class T_functor, class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5>
312 /** Invokes a functor of type @p T_functor.
313 * @param rep slot_rep object that holds a functor of type @p T_functor.
314 * @param _A_a1 Argument to be passed on to the functor.
315 * @param _A_a2 Argument to be passed on to the functor.
316 * @param _A_a3 Argument to be passed on to the functor.
317 * @param _A_a4 Argument to be passed on to the functor.
318 * @param _A_a5 Argument to be passed on to the functor.
319 * @return The return values of the functor invocation.
321 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2, type_trait_take_t<T_arg3> a_3, type_trait_take_t<T_arg4> a_4, type_trait_take_t<T_arg5> a_5)
323 typedef typed_slot_rep<T_functor> typed_slot;
324 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
325 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>, type_trait_take_t<T_arg3>, type_trait_take_t<T_arg4>, type_trait_take_t<T_arg5>>
326 (a_1, a_2, a_3, a_4, a_5);
329 /** Forms a function pointer from call_it().
330 * @return A function pointer formed from call_it().
332 static hook address()
333 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
336 /** Abstracts functor execution.
337 * call_it() invokes a functor of type @e T_functor with a list of
338 * parameters whose types are given by the template arguments.
339 * address() forms a function pointer from call_it().
341 * The following template arguments are used:
342 * - @e T_functor The functor type.
343 * - @e T_return The return type of call_it().
344 * - @e T_arg1 Argument type used in the definition of call_it().
345 * - @e T_arg2 Argument type used in the definition of call_it().
346 * - @e T_arg3 Argument type used in the definition of call_it().
347 * - @e T_arg4 Argument type used in the definition of call_it().
348 * - @e T_arg5 Argument type used in the definition of call_it().
349 * - @e T_arg6 Argument type used in the definition of call_it().
352 template<class T_functor, class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6>
355 /** Invokes a functor of type @p T_functor.
356 * @param rep slot_rep object that holds a functor of type @p T_functor.
357 * @param _A_a1 Argument to be passed on to the functor.
358 * @param _A_a2 Argument to be passed on to the functor.
359 * @param _A_a3 Argument to be passed on to the functor.
360 * @param _A_a4 Argument to be passed on to the functor.
361 * @param _A_a5 Argument to be passed on to the functor.
362 * @param _A_a6 Argument to be passed on to the functor.
363 * @return The return values of the functor invocation.
365 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2, type_trait_take_t<T_arg3> a_3, type_trait_take_t<T_arg4> a_4, type_trait_take_t<T_arg5> a_5, type_trait_take_t<T_arg6> a_6)
367 typedef typed_slot_rep<T_functor> typed_slot;
368 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
369 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>, type_trait_take_t<T_arg3>, type_trait_take_t<T_arg4>, type_trait_take_t<T_arg5>, type_trait_take_t<T_arg6>>
370 (a_1, a_2, a_3, a_4, a_5, a_6);
373 /** Forms a function pointer from call_it().
374 * @return A function pointer formed from call_it().
376 static hook address()
377 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
380 /** Abstracts functor execution.
381 * call_it() invokes a functor of type @e T_functor with a list of
382 * parameters whose types are given by the template arguments.
383 * address() forms a function pointer from call_it().
385 * The following template arguments are used:
386 * - @e T_functor The functor type.
387 * - @e T_return The return type of call_it().
388 * - @e T_arg1 Argument type used in the definition of call_it().
389 * - @e T_arg2 Argument type used in the definition of call_it().
390 * - @e T_arg3 Argument type used in the definition of call_it().
391 * - @e T_arg4 Argument type used in the definition of call_it().
392 * - @e T_arg5 Argument type used in the definition of call_it().
393 * - @e T_arg6 Argument type used in the definition of call_it().
394 * - @e T_arg7 Argument type used in the definition of call_it().
397 template<class T_functor, class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7>
400 /** Invokes a functor of type @p T_functor.
401 * @param rep slot_rep object that holds a functor of type @p T_functor.
402 * @param _A_a1 Argument to be passed on to the functor.
403 * @param _A_a2 Argument to be passed on to the functor.
404 * @param _A_a3 Argument to be passed on to the functor.
405 * @param _A_a4 Argument to be passed on to the functor.
406 * @param _A_a5 Argument to be passed on to the functor.
407 * @param _A_a6 Argument to be passed on to the functor.
408 * @param _A_a7 Argument to be passed on to the functor.
409 * @return The return values of the functor invocation.
411 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg1> a_1, type_trait_take_t<T_arg2> a_2, type_trait_take_t<T_arg3> a_3, type_trait_take_t<T_arg4> a_4, type_trait_take_t<T_arg5> a_5, type_trait_take_t<T_arg6> a_6, type_trait_take_t<T_arg7> a_7)
413 typedef typed_slot_rep<T_functor> typed_slot;
414 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
415 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg1>, type_trait_take_t<T_arg2>, type_trait_take_t<T_arg3>, type_trait_take_t<T_arg4>, type_trait_take_t<T_arg5>, type_trait_take_t<T_arg6>, type_trait_take_t<T_arg7>>
416 (a_1, a_2, a_3, a_4, a_5, a_6, a_7);
419 /** Forms a function pointer from call_it().
420 * @return A function pointer formed from call_it().
422 static hook address()
423 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
427 /** Abstracts functor execution.
428 * call_it() invokes a functor of type @e T_functor with a list of
429 * parameters whose types are given by the template arguments.
430 * address() forms a function pointer from call_it().
432 * The following template arguments are used:
433 * - @e T_functor The functor type.
434 * - @e T_return The return type of call_it().
435 * - @e T_arg Argument types used in the definition of call_it().
438 template<class T_functor, class T_return, class... T_arg>
441 /** Invokes a functor of type @p T_functor.
442 * @param rep slot_rep object that holds a functor of type @p T_functor.
443 * @param _A_a Arguments to be passed on to the functor.
444 * @return The return values of the functor invocation.
446 static T_return call_it(slot_rep* rep, type_trait_take_t<T_arg>... a_)
448 using typed_slot = typed_slot_rep<T_functor>;
449 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
450 return (typed_rep->functor_).SIGC_WORKAROUND_OPERATOR_PARENTHESES<type_trait_take_t<T_arg>...>
454 /** Forms a function pointer from call_it().
455 * @return A function pointer formed from call_it().
457 static hook address()
458 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
461 /** Abstracts functor execution.
462 * call_it() invokes a functor without parameters of type @e T_functor.
463 * address() forms a function pointer from call_it().
465 * This is a specialization for functors without parameters.
467 * The following template arguments are used:
468 * - @e T_functor The functor type.
469 * - @e T_return The return type of call_it().
472 template<class T_functor, class T_return>
473 struct slot_call<T_functor, T_return>
475 /** Invokes a functor of type @p T_functor.
476 * @param rep slot_rep object that holds a functor of type @p T_functor.
477 * @return The return values of the functor invocation.
479 static T_return call_it(slot_rep* rep)
481 using typed_slot = typed_slot_rep<T_functor>;
482 typed_slot *typed_rep = static_cast<typed_slot*>(rep);
483 return (typed_rep->functor_)();
486 /** Forms a function pointer from call_it().
487 * @return A function pointer formed from call_it().
489 static hook address()
490 { return sigc::internal::function_pointer_cast<hook>(&call_it); }
493 } /* namespace internal */
496 /** Converts an arbitrary functor to a unified type which is opaque.
497 * sigc::slot itself is a functor or to be more precise a closure. It contains
498 * a single, arbitrary functor (or closure) that is executed in operator()().
500 * The template arguments determine the function signature of operator()():
501 * - @e T_return The return type of operator()().
503 * To use simply assign the desired functor to the slot. If the functor
504 * is not compatible with the parameter list defined with the template
505 * arguments compiler errors are triggered. When called the slot
506 * will invoke the functor with minimal copies.
507 * block() and unblock() can be used to block the functor's invocation
508 * from operator()() temporarily.
510 * You should use the more convenient unnumbered sigc::slot template.
514 template <class T_return>
519 typedef T_return result_type;
522 #ifndef DOXYGEN_SHOULD_SKIP_THIS
524 typedef internal::slot_rep rep_type;
526 typedef T_return (*call_type)(rep_type*);
529 /** Invoke the contained functor unless slot is in blocking state.
530 * @return The return value of the functor invocation.
532 inline T_return operator()() const
534 if (!empty() && !blocked())
535 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_);
541 /** Constructs a slot from an arbitrary functor.
542 * @param _A_func The desired functor the new slot should be assigned to.
544 template <class T_functor>
545 slot0(const T_functor& _A_func)
546 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
548 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
549 slot_base::rep_->call_ = internal::slot_call0<T_functor, T_return>::address();
552 /** Constructs a slot, copying an existing one.
553 * @param src The existing slot to copy.
555 slot0(const slot0& src)
559 /** Constructs a slot, moving an existing one.
560 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
561 * @param src The existing slot to move or copy.
564 : slot_base(std::move(src))
567 /** Overrides this slot, making a copy from another slot.
568 * @param src The slot from which to make a copy.
571 slot0& operator=(const slot0& src)
573 slot_base::operator=(src);
577 /** Overrides this slot, making a move from another slot.
578 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
579 * @param src The slot from which to move or copy.
582 slot0& operator=(slot0&& src)
584 slot_base::operator=(std::move(src));
589 #ifndef DOXYGEN_SHOULD_SKIP_THIS
590 //template specialization of visitor<>::do_visit_each<>(action, functor):
591 /** Performs a functor on each of the targets of a functor.
592 * The function overloads for sigc::slot0 are similar to the function
593 * overloads for sigc::slot. See the description of those overloads.
597 template <typename T_return>
598 struct visitor<slot0<T_return>>
600 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
601 const slot0<T_return>& _A_target)
603 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
604 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
607 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
608 const slot0<T_return>& _A_target)
610 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
611 _A_target.rep_->set_parent(nullptr, nullptr);
614 template <typename T_action>
615 static void do_visit_each(const T_action& _A_action,
616 const slot0<T_return>& _A_target)
618 _A_action(_A_target);
621 #endif // DOXYGEN_SHOULD_SKIP_THIS
623 /** Converts an arbitrary functor to a unified type which is opaque.
624 * sigc::slot itself is a functor or to be more precise a closure. It contains
625 * a single, arbitrary functor (or closure) that is executed in operator()().
627 * The template arguments determine the function signature of operator()():
628 * - @e T_return The return type of operator()().
629 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
631 * To use simply assign the desired functor to the slot. If the functor
632 * is not compatible with the parameter list defined with the template
633 * arguments compiler errors are triggered. When called the slot
634 * will invoke the functor with minimal copies.
635 * block() and unblock() can be used to block the functor's invocation
636 * from operator()() temporarily.
638 * You should use the more convenient unnumbered sigc::slot template.
642 template <class T_return, class T_arg1>
647 typedef T_return result_type;
648 typedef type_trait_take_t<T_arg1> arg1_type_;
651 #ifndef DOXYGEN_SHOULD_SKIP_THIS
653 typedef internal::slot_rep rep_type;
655 typedef T_return (*call_type)(rep_type*, arg1_type_);
658 /** Invoke the contained functor unless slot is in blocking state.
659 * @param _A_a1 Argument to be passed on to the functor.
660 * @return The return value of the functor invocation.
662 inline T_return operator()(arg1_type_ _A_a1) const
664 if (!empty() && !blocked())
665 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1);
671 /** Constructs a slot from an arbitrary functor.
672 * @param _A_func The desired functor the new slot should be assigned to.
674 template <class T_functor>
675 slot1(const T_functor& _A_func)
676 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
678 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
679 slot_base::rep_->call_ = internal::slot_call1<T_functor, T_return, T_arg1>::address();
682 /** Constructs a slot, copying an existing one.
683 * @param src The existing slot to copy.
685 slot1(const slot1& src)
689 /** Constructs a slot, moving an existing one.
690 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
691 * @param src The existing slot to move or copy.
694 : slot_base(std::move(src))
697 /** Overrides this slot, making a copy from another slot.
698 * @param src The slot from which to make a copy.
701 slot1& operator=(const slot1& src)
703 slot_base::operator=(src);
707 /** Overrides this slot, making a move from another slot.
708 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
709 * @param src The slot from which to move or copy.
712 slot1& operator=(slot1&& src)
714 slot_base::operator=(std::move(src));
719 #ifndef DOXYGEN_SHOULD_SKIP_THIS
720 //template specialization of visitor<>::do_visit_each<>(action, functor):
721 /** Performs a functor on each of the targets of a functor.
722 * The function overloads for sigc::slot1 are similar to the function
723 * overloads for sigc::slot. See the description of those overloads.
727 template <typename T_return, typename T_arg1>
728 struct visitor<slot1<T_return, T_arg1>>
730 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
731 const slot1<T_return, T_arg1>& _A_target)
733 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
734 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
737 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
738 const slot1<T_return, T_arg1>& _A_target)
740 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
741 _A_target.rep_->set_parent(nullptr, nullptr);
744 template <typename T_action>
745 static void do_visit_each(const T_action& _A_action,
746 const slot1<T_return, T_arg1>& _A_target)
748 _A_action(_A_target);
751 #endif // DOXYGEN_SHOULD_SKIP_THIS
753 /** Converts an arbitrary functor to a unified type which is opaque.
754 * sigc::slot itself is a functor or to be more precise a closure. It contains
755 * a single, arbitrary functor (or closure) that is executed in operator()().
757 * The template arguments determine the function signature of operator()():
758 * - @e T_return The return type of operator()().
759 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
760 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
762 * To use simply assign the desired functor to the slot. If the functor
763 * is not compatible with the parameter list defined with the template
764 * arguments compiler errors are triggered. When called the slot
765 * will invoke the functor with minimal copies.
766 * block() and unblock() can be used to block the functor's invocation
767 * from operator()() temporarily.
769 * You should use the more convenient unnumbered sigc::slot template.
773 template <class T_return, class T_arg1, class T_arg2>
778 typedef T_return result_type;
779 typedef type_trait_take_t<T_arg1> arg1_type_;
780 typedef type_trait_take_t<T_arg2> arg2_type_;
783 #ifndef DOXYGEN_SHOULD_SKIP_THIS
785 typedef internal::slot_rep rep_type;
787 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_);
790 /** Invoke the contained functor unless slot is in blocking state.
791 * @param _A_a1 Argument to be passed on to the functor.
792 * @param _A_a2 Argument to be passed on to the functor.
793 * @return The return value of the functor invocation.
795 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2) const
797 if (!empty() && !blocked())
798 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2);
804 /** Constructs a slot from an arbitrary functor.
805 * @param _A_func The desired functor the new slot should be assigned to.
807 template <class T_functor>
808 slot2(const T_functor& _A_func)
809 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
811 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
812 slot_base::rep_->call_ = internal::slot_call2<T_functor, T_return, T_arg1, T_arg2>::address();
815 /** Constructs a slot, copying an existing one.
816 * @param src The existing slot to copy.
818 slot2(const slot2& src)
822 /** Constructs a slot, moving an existing one.
823 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
824 * @param src The existing slot to move or copy.
827 : slot_base(std::move(src))
830 /** Overrides this slot, making a copy from another slot.
831 * @param src The slot from which to make a copy.
834 slot2& operator=(const slot2& src)
836 slot_base::operator=(src);
840 /** Overrides this slot, making a move from another slot.
841 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
842 * @param src The slot from which to move or copy.
845 slot2& operator=(slot2&& src)
847 slot_base::operator=(std::move(src));
852 #ifndef DOXYGEN_SHOULD_SKIP_THIS
853 //template specialization of visitor<>::do_visit_each<>(action, functor):
854 /** Performs a functor on each of the targets of a functor.
855 * The function overloads for sigc::slot2 are similar to the function
856 * overloads for sigc::slot. See the description of those overloads.
860 template <typename T_return, typename T_arg1, typename T_arg2>
861 struct visitor<slot2<T_return, T_arg1, T_arg2>>
863 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
864 const slot2<T_return, T_arg1, T_arg2>& _A_target)
866 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
867 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
870 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
871 const slot2<T_return, T_arg1, T_arg2>& _A_target)
873 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
874 _A_target.rep_->set_parent(nullptr, nullptr);
877 template <typename T_action>
878 static void do_visit_each(const T_action& _A_action,
879 const slot2<T_return, T_arg1, T_arg2>& _A_target)
881 _A_action(_A_target);
884 #endif // DOXYGEN_SHOULD_SKIP_THIS
886 /** Converts an arbitrary functor to a unified type which is opaque.
887 * sigc::slot itself is a functor or to be more precise a closure. It contains
888 * a single, arbitrary functor (or closure) that is executed in operator()().
890 * The template arguments determine the function signature of operator()():
891 * - @e T_return The return type of operator()().
892 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
893 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
894 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
896 * To use simply assign the desired functor to the slot. If the functor
897 * is not compatible with the parameter list defined with the template
898 * arguments compiler errors are triggered. When called the slot
899 * will invoke the functor with minimal copies.
900 * block() and unblock() can be used to block the functor's invocation
901 * from operator()() temporarily.
903 * You should use the more convenient unnumbered sigc::slot template.
907 template <class T_return, class T_arg1, class T_arg2, class T_arg3>
912 typedef T_return result_type;
913 typedef type_trait_take_t<T_arg1> arg1_type_;
914 typedef type_trait_take_t<T_arg2> arg2_type_;
915 typedef type_trait_take_t<T_arg3> arg3_type_;
918 #ifndef DOXYGEN_SHOULD_SKIP_THIS
920 typedef internal::slot_rep rep_type;
922 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_, arg3_type_);
925 /** Invoke the contained functor unless slot is in blocking state.
926 * @param _A_a1 Argument to be passed on to the functor.
927 * @param _A_a2 Argument to be passed on to the functor.
928 * @param _A_a3 Argument to be passed on to the functor.
929 * @return The return value of the functor invocation.
931 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2, arg3_type_ _A_a3) const
933 if (!empty() && !blocked())
934 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2, _A_a3);
940 /** Constructs a slot from an arbitrary functor.
941 * @param _A_func The desired functor the new slot should be assigned to.
943 template <class T_functor>
944 slot3(const T_functor& _A_func)
945 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
947 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
948 slot_base::rep_->call_ = internal::slot_call3<T_functor, T_return, T_arg1, T_arg2, T_arg3>::address();
951 /** Constructs a slot, copying an existing one.
952 * @param src The existing slot to copy.
954 slot3(const slot3& src)
958 /** Constructs a slot, moving an existing one.
959 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
960 * @param src The existing slot to move or copy.
963 : slot_base(std::move(src))
966 /** Overrides this slot, making a copy from another slot.
967 * @param src The slot from which to make a copy.
970 slot3& operator=(const slot3& src)
972 slot_base::operator=(src);
976 /** Overrides this slot, making a move from another slot.
977 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
978 * @param src The slot from which to move or copy.
981 slot3& operator=(slot3&& src)
983 slot_base::operator=(std::move(src));
988 #ifndef DOXYGEN_SHOULD_SKIP_THIS
989 //template specialization of visitor<>::do_visit_each<>(action, functor):
990 /** Performs a functor on each of the targets of a functor.
991 * The function overloads for sigc::slot3 are similar to the function
992 * overloads for sigc::slot. See the description of those overloads.
996 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3>
997 struct visitor<slot3<T_return, T_arg1, T_arg2, T_arg3>>
999 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1000 const slot3<T_return, T_arg1, T_arg2, T_arg3>& _A_target)
1002 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1003 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1006 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1007 const slot3<T_return, T_arg1, T_arg2, T_arg3>& _A_target)
1009 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1010 _A_target.rep_->set_parent(nullptr, nullptr);
1013 template <typename T_action>
1014 static void do_visit_each(const T_action& _A_action,
1015 const slot3<T_return, T_arg1, T_arg2, T_arg3>& _A_target)
1017 _A_action(_A_target);
1020 #endif // DOXYGEN_SHOULD_SKIP_THIS
1022 /** Converts an arbitrary functor to a unified type which is opaque.
1023 * sigc::slot itself is a functor or to be more precise a closure. It contains
1024 * a single, arbitrary functor (or closure) that is executed in operator()().
1026 * The template arguments determine the function signature of operator()():
1027 * - @e T_return The return type of operator()().
1028 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
1029 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
1030 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
1031 * - @e T_arg4 Argument type used in the definition of operator()(). The default @p nil means no argument.
1033 * To use simply assign the desired functor to the slot. If the functor
1034 * is not compatible with the parameter list defined with the template
1035 * arguments compiler errors are triggered. When called the slot
1036 * will invoke the functor with minimal copies.
1037 * block() and unblock() can be used to block the functor's invocation
1038 * from operator()() temporarily.
1040 * You should use the more convenient unnumbered sigc::slot template.
1044 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4>
1049 typedef T_return result_type;
1050 typedef type_trait_take_t<T_arg1> arg1_type_;
1051 typedef type_trait_take_t<T_arg2> arg2_type_;
1052 typedef type_trait_take_t<T_arg3> arg3_type_;
1053 typedef type_trait_take_t<T_arg4> arg4_type_;
1056 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1058 typedef internal::slot_rep rep_type;
1060 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_, arg3_type_, arg4_type_);
1063 /** Invoke the contained functor unless slot is in blocking state.
1064 * @param _A_a1 Argument to be passed on to the functor.
1065 * @param _A_a2 Argument to be passed on to the functor.
1066 * @param _A_a3 Argument to be passed on to the functor.
1067 * @param _A_a4 Argument to be passed on to the functor.
1068 * @return The return value of the functor invocation.
1070 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2, arg3_type_ _A_a3, arg4_type_ _A_a4) const
1072 if (!empty() && !blocked())
1073 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2, _A_a3, _A_a4);
1079 /** Constructs a slot from an arbitrary functor.
1080 * @param _A_func The desired functor the new slot should be assigned to.
1082 template <class T_functor>
1083 slot4(const T_functor& _A_func)
1084 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
1086 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
1087 slot_base::rep_->call_ = internal::slot_call4<T_functor, T_return, T_arg1, T_arg2, T_arg3, T_arg4>::address();
1090 /** Constructs a slot, copying an existing one.
1091 * @param src The existing slot to copy.
1093 slot4(const slot4& src)
1097 /** Constructs a slot, moving an existing one.
1098 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1099 * @param src The existing slot to move or copy.
1102 : slot_base(std::move(src))
1105 /** Overrides this slot, making a copy from another slot.
1106 * @param src The slot from which to make a copy.
1109 slot4& operator=(const slot4& src)
1111 slot_base::operator=(src);
1115 /** Overrides this slot, making a move from another slot.
1116 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1117 * @param src The slot from which to move or copy.
1120 slot4& operator=(slot4&& src)
1122 slot_base::operator=(std::move(src));
1127 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1128 //template specialization of visitor<>::do_visit_each<>(action, functor):
1129 /** Performs a functor on each of the targets of a functor.
1130 * The function overloads for sigc::slot4 are similar to the function
1131 * overloads for sigc::slot. See the description of those overloads.
1135 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4>
1136 struct visitor<slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4>>
1138 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1139 const slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4>& _A_target)
1141 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1142 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1145 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1146 const slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4>& _A_target)
1148 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1149 _A_target.rep_->set_parent(nullptr, nullptr);
1152 template <typename T_action>
1153 static void do_visit_each(const T_action& _A_action,
1154 const slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4>& _A_target)
1156 _A_action(_A_target);
1159 #endif // DOXYGEN_SHOULD_SKIP_THIS
1161 /** Converts an arbitrary functor to a unified type which is opaque.
1162 * sigc::slot itself is a functor or to be more precise a closure. It contains
1163 * a single, arbitrary functor (or closure) that is executed in operator()().
1165 * The template arguments determine the function signature of operator()():
1166 * - @e T_return The return type of operator()().
1167 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
1168 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
1169 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
1170 * - @e T_arg4 Argument type used in the definition of operator()(). The default @p nil means no argument.
1171 * - @e T_arg5 Argument type used in the definition of operator()(). The default @p nil means no argument.
1173 * To use simply assign the desired functor to the slot. If the functor
1174 * is not compatible with the parameter list defined with the template
1175 * arguments compiler errors are triggered. When called the slot
1176 * will invoke the functor with minimal copies.
1177 * block() and unblock() can be used to block the functor's invocation
1178 * from operator()() temporarily.
1180 * You should use the more convenient unnumbered sigc::slot template.
1184 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5>
1189 typedef T_return result_type;
1190 typedef type_trait_take_t<T_arg1> arg1_type_;
1191 typedef type_trait_take_t<T_arg2> arg2_type_;
1192 typedef type_trait_take_t<T_arg3> arg3_type_;
1193 typedef type_trait_take_t<T_arg4> arg4_type_;
1194 typedef type_trait_take_t<T_arg5> arg5_type_;
1197 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1199 typedef internal::slot_rep rep_type;
1201 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_, arg3_type_, arg4_type_, arg5_type_);
1204 /** Invoke the contained functor unless slot is in blocking state.
1205 * @param _A_a1 Argument to be passed on to the functor.
1206 * @param _A_a2 Argument to be passed on to the functor.
1207 * @param _A_a3 Argument to be passed on to the functor.
1208 * @param _A_a4 Argument to be passed on to the functor.
1209 * @param _A_a5 Argument to be passed on to the functor.
1210 * @return The return value of the functor invocation.
1212 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2, arg3_type_ _A_a3, arg4_type_ _A_a4, arg5_type_ _A_a5) const
1214 if (!empty() && !blocked())
1215 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2, _A_a3, _A_a4, _A_a5);
1221 /** Constructs a slot from an arbitrary functor.
1222 * @param _A_func The desired functor the new slot should be assigned to.
1224 template <class T_functor>
1225 slot5(const T_functor& _A_func)
1226 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
1228 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
1229 slot_base::rep_->call_ = internal::slot_call5<T_functor, T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>::address();
1232 /** Constructs a slot, copying an existing one.
1233 * @param src The existing slot to copy.
1235 slot5(const slot5& src)
1239 /** Constructs a slot, moving an existing one.
1240 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1241 * @param src The existing slot to move or copy.
1244 : slot_base(std::move(src))
1247 /** Overrides this slot, making a copy from another slot.
1248 * @param src The slot from which to make a copy.
1251 slot5& operator=(const slot5& src)
1253 slot_base::operator=(src);
1257 /** Overrides this slot, making a move from another slot.
1258 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1259 * @param src The slot from which to move or copy.
1262 slot5& operator=(slot5&& src)
1264 slot_base::operator=(std::move(src));
1269 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1270 //template specialization of visitor<>::do_visit_each<>(action, functor):
1271 /** Performs a functor on each of the targets of a functor.
1272 * The function overloads for sigc::slot5 are similar to the function
1273 * overloads for sigc::slot. See the description of those overloads.
1277 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5>
1278 struct visitor<slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>>
1280 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1281 const slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>& _A_target)
1283 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1284 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1287 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1288 const slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>& _A_target)
1290 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1291 _A_target.rep_->set_parent(nullptr, nullptr);
1294 template <typename T_action>
1295 static void do_visit_each(const T_action& _A_action,
1296 const slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>& _A_target)
1298 _A_action(_A_target);
1301 #endif // DOXYGEN_SHOULD_SKIP_THIS
1303 /** Converts an arbitrary functor to a unified type which is opaque.
1304 * sigc::slot itself is a functor or to be more precise a closure. It contains
1305 * a single, arbitrary functor (or closure) that is executed in operator()().
1307 * The template arguments determine the function signature of operator()():
1308 * - @e T_return The return type of operator()().
1309 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
1310 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
1311 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
1312 * - @e T_arg4 Argument type used in the definition of operator()(). The default @p nil means no argument.
1313 * - @e T_arg5 Argument type used in the definition of operator()(). The default @p nil means no argument.
1314 * - @e T_arg6 Argument type used in the definition of operator()(). The default @p nil means no argument.
1316 * To use simply assign the desired functor to the slot. If the functor
1317 * is not compatible with the parameter list defined with the template
1318 * arguments compiler errors are triggered. When called the slot
1319 * will invoke the functor with minimal copies.
1320 * block() and unblock() can be used to block the functor's invocation
1321 * from operator()() temporarily.
1323 * You should use the more convenient unnumbered sigc::slot template.
1327 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6>
1332 typedef T_return result_type;
1333 typedef type_trait_take_t<T_arg1> arg1_type_;
1334 typedef type_trait_take_t<T_arg2> arg2_type_;
1335 typedef type_trait_take_t<T_arg3> arg3_type_;
1336 typedef type_trait_take_t<T_arg4> arg4_type_;
1337 typedef type_trait_take_t<T_arg5> arg5_type_;
1338 typedef type_trait_take_t<T_arg6> arg6_type_;
1341 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1343 typedef internal::slot_rep rep_type;
1345 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_, arg3_type_, arg4_type_, arg5_type_, arg6_type_);
1348 /** Invoke the contained functor unless slot is in blocking state.
1349 * @param _A_a1 Argument to be passed on to the functor.
1350 * @param _A_a2 Argument to be passed on to the functor.
1351 * @param _A_a3 Argument to be passed on to the functor.
1352 * @param _A_a4 Argument to be passed on to the functor.
1353 * @param _A_a5 Argument to be passed on to the functor.
1354 * @param _A_a6 Argument to be passed on to the functor.
1355 * @return The return value of the functor invocation.
1357 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2, arg3_type_ _A_a3, arg4_type_ _A_a4, arg5_type_ _A_a5, arg6_type_ _A_a6) const
1359 if (!empty() && !blocked())
1360 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6);
1366 /** Constructs a slot from an arbitrary functor.
1367 * @param _A_func The desired functor the new slot should be assigned to.
1369 template <class T_functor>
1370 slot6(const T_functor& _A_func)
1371 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
1373 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
1374 slot_base::rep_->call_ = internal::slot_call6<T_functor, T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>::address();
1377 /** Constructs a slot, copying an existing one.
1378 * @param src The existing slot to copy.
1380 slot6(const slot6& src)
1384 /** Constructs a slot, moving an existing one.
1385 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1386 * @param src The existing slot to move or copy.
1389 : slot_base(std::move(src))
1392 /** Overrides this slot, making a copy from another slot.
1393 * @param src The slot from which to make a copy.
1396 slot6& operator=(const slot6& src)
1398 slot_base::operator=(src);
1402 /** Overrides this slot, making a move from another slot.
1403 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1404 * @param src The slot from which to move or copy.
1407 slot6& operator=(slot6&& src)
1409 slot_base::operator=(std::move(src));
1414 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1415 //template specialization of visitor<>::do_visit_each<>(action, functor):
1416 /** Performs a functor on each of the targets of a functor.
1417 * The function overloads for sigc::slot6 are similar to the function
1418 * overloads for sigc::slot. See the description of those overloads.
1422 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6>
1423 struct visitor<slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>>
1425 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1426 const slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>& _A_target)
1428 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1429 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1432 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1433 const slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>& _A_target)
1435 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1436 _A_target.rep_->set_parent(nullptr, nullptr);
1439 template <typename T_action>
1440 static void do_visit_each(const T_action& _A_action,
1441 const slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>& _A_target)
1443 _A_action(_A_target);
1446 #endif // DOXYGEN_SHOULD_SKIP_THIS
1448 /** Converts an arbitrary functor to a unified type which is opaque.
1449 * sigc::slot itself is a functor or to be more precise a closure. It contains
1450 * a single, arbitrary functor (or closure) that is executed in operator()().
1452 * The template arguments determine the function signature of operator()():
1453 * - @e T_return The return type of operator()().
1454 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
1455 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
1456 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
1457 * - @e T_arg4 Argument type used in the definition of operator()(). The default @p nil means no argument.
1458 * - @e T_arg5 Argument type used in the definition of operator()(). The default @p nil means no argument.
1459 * - @e T_arg6 Argument type used in the definition of operator()(). The default @p nil means no argument.
1460 * - @e T_arg7 Argument type used in the definition of operator()(). The default @p nil means no argument.
1462 * To use simply assign the desired functor to the slot. If the functor
1463 * is not compatible with the parameter list defined with the template
1464 * arguments compiler errors are triggered. When called the slot
1465 * will invoke the functor with minimal copies.
1466 * block() and unblock() can be used to block the functor's invocation
1467 * from operator()() temporarily.
1469 * You should use the more convenient unnumbered sigc::slot template.
1473 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7>
1478 typedef T_return result_type;
1479 typedef type_trait_take_t<T_arg1> arg1_type_;
1480 typedef type_trait_take_t<T_arg2> arg2_type_;
1481 typedef type_trait_take_t<T_arg3> arg3_type_;
1482 typedef type_trait_take_t<T_arg4> arg4_type_;
1483 typedef type_trait_take_t<T_arg5> arg5_type_;
1484 typedef type_trait_take_t<T_arg6> arg6_type_;
1485 typedef type_trait_take_t<T_arg7> arg7_type_;
1488 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1490 typedef internal::slot_rep rep_type;
1492 typedef T_return (*call_type)(rep_type*, arg1_type_, arg2_type_, arg3_type_, arg4_type_, arg5_type_, arg6_type_, arg7_type_);
1495 /** Invoke the contained functor unless slot is in blocking state.
1496 * @param _A_a1 Argument to be passed on to the functor.
1497 * @param _A_a2 Argument to be passed on to the functor.
1498 * @param _A_a3 Argument to be passed on to the functor.
1499 * @param _A_a4 Argument to be passed on to the functor.
1500 * @param _A_a5 Argument to be passed on to the functor.
1501 * @param _A_a6 Argument to be passed on to the functor.
1502 * @param _A_a7 Argument to be passed on to the functor.
1503 * @return The return value of the functor invocation.
1505 inline T_return operator()(arg1_type_ _A_a1, arg2_type_ _A_a2, arg3_type_ _A_a3, arg4_type_ _A_a4, arg5_type_ _A_a5, arg6_type_ _A_a6, arg7_type_ _A_a7) const
1507 if (!empty() && !blocked())
1508 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6, _A_a7);
1514 /** Constructs a slot from an arbitrary functor.
1515 * @param _A_func The desired functor the new slot should be assigned to.
1517 template <class T_functor>
1518 slot7(const T_functor& _A_func)
1519 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
1521 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
1522 slot_base::rep_->call_ = internal::slot_call7<T_functor, T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>::address();
1525 /** Constructs a slot, copying an existing one.
1526 * @param src The existing slot to copy.
1528 slot7(const slot7& src)
1532 /** Constructs a slot, moving an existing one.
1533 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1534 * @param src The existing slot to move or copy.
1537 : slot_base(std::move(src))
1540 /** Overrides this slot, making a copy from another slot.
1541 * @param src The slot from which to make a copy.
1544 slot7& operator=(const slot7& src)
1546 slot_base::operator=(src);
1550 /** Overrides this slot, making a move from another slot.
1551 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1552 * @param src The slot from which to move or copy.
1555 slot7& operator=(slot7&& src)
1557 slot_base::operator=(std::move(src));
1562 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1563 //template specialization of visitor<>::do_visit_each<>(action, functor):
1564 /** Performs a functor on each of the targets of a functor.
1565 * The function overloads for sigc::slot7 are similar to the function
1566 * overloads for sigc::slot. See the description of those overloads.
1570 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
1571 struct visitor<slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>>
1573 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1574 const slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1576 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1577 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1580 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1581 const slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1583 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1584 _A_target.rep_->set_parent(nullptr, nullptr);
1587 template <typename T_action>
1588 static void do_visit_each(const T_action& _A_action,
1589 const slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1591 _A_action(_A_target);
1594 #endif // DOXYGEN_SHOULD_SKIP_THIS
1597 // Because slot is opaque, visit_each() will not visit its internal members.
1598 // Those members are not reachable by visit_each() after the slot has been
1599 // constructed. But when a slot contains another slot, the outer slot will become
1600 // the parent of the inner slot, with similar results. See the description of
1601 // slot's specialization of the visitor struct.
1602 /** Convenience wrapper for the numbered sigc::slot# templates.
1603 * Slots convert arbitrary functors to unified types which are opaque.
1604 * sigc::slot itself is a functor or to be more precise a closure. It contains
1605 * a single, arbitrary functor (or closure) that is executed in operator()().
1607 * The template arguments determine the function signature of operator()():
1608 * - @e T_return The return type of operator()().
1609 * - @e T_arg1 Argument type used in the definition of operator()(). The default @p nil means no argument.
1610 * - @e T_arg2 Argument type used in the definition of operator()(). The default @p nil means no argument.
1611 * - @e T_arg3 Argument type used in the definition of operator()(). The default @p nil means no argument.
1612 * - @e T_arg4 Argument type used in the definition of operator()(). The default @p nil means no argument.
1613 * - @e T_arg5 Argument type used in the definition of operator()(). The default @p nil means no argument.
1614 * - @e T_arg6 Argument type used in the definition of operator()(). The default @p nil means no argument.
1615 * - @e T_arg7 Argument type used in the definition of operator()(). The default @p nil means no argument.
1617 * To use, simply assign the desired functor to the slot. If the functor
1618 * is not compatible with the parameter list defined with the template
1619 * arguments, compiler errors are triggered. When called, the slot
1620 * will invoke the functor with minimal copies.
1621 * block() and unblock() can be used to temporarily block the functor's
1622 * invocation from operator()().
1627 * sigc::slot<void, int> s = sigc::ptr_fun(&foo);
1631 * sigc::slot<> is similar to std::function<>. If you're going to assign the
1632 * resulting functor to a sigc::slot or connect it to a sigc::signal, it's better
1633 * not to use std::function. It would become an unnecessary extra wrapper.
1635 * @deprecated Please use the syntax similar to that used by std::function<>:
1637 * sigc::slot<void(bool, int)> some_slot;
1642 template <class T_return, class T_arg1 = nil, class T_arg2 = nil, class T_arg3 = nil, class T_arg4 = nil, class T_arg5 = nil, class T_arg6 = nil, class T_arg7 = nil>
1644 : public slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>
1647 typedef slot7<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7> parent_type;
1651 /** Constructs a slot from an arbitrary functor.
1652 * @param _A_func The desired functor the new slot should be assigned to.
1654 template <class T_functor>
1655 slot(const T_functor& _A_func)
1656 : parent_type(_A_func) {}
1658 // Without static_cast parent_type(const T_functor& _A_func)
1659 // is called instead of the copy constructor.
1660 /** Constructs a slot, copying an existing one.
1661 * @param src The existing slot to copy.
1663 slot(const slot& src)
1664 : parent_type(static_cast<const parent_type&>(src)) {}
1666 // Without static_cast parent_type(const T_functor& _A_func)
1667 // is called instead of the move constructor.
1668 /** Constructs a slot, moving an existing one.
1669 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1670 * @param src The existing slot to move or copy.
1673 : parent_type(std::move(static_cast<parent_type&>(src))) {}
1675 /** Overrides this slot, making a copy from another slot.
1676 * @param src The slot from which to make a copy.
1679 slot& operator=(const slot& src)
1681 parent_type::operator=(src);
1685 /** Overrides this slot, making a move from another slot.
1686 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1687 * @param src The slot from which to move or copy.
1690 slot& operator=(slot&& src)
1692 parent_type::operator=(std::move(src));
1697 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1698 //template specialization of visitor<>::do_visit_each<>(action, functor):
1699 /** Performs a functor on each of the targets of a functor.
1701 * There are three function overloads for sigc::slot.
1703 * The first two overloads are very specialized. They handle the (probably unusual)
1704 * case when the functor, stored in a slot, contains a slot. They are invoked from
1705 * the constructor, destructor or destroy() method of typed_slot_rep.
1706 * The first overload, called from the constructor of the outer slot, sets
1707 * the outer slot as the parent of the inner slot. The second overload, called from
1708 * the destructor or destroy() of the outer slot, unsets the parent of the inner slot.
1709 * When an object referenced from the inner slot is deleted, the inner slot calls
1710 * its slot_rep::disconnect(), which calls the outer slot's slot_rep::notify().
1711 * The outer slot is informed just as if one of its directly referenced objects
1712 * had been deleted. Result: The outer slot is disconnected from its parent,
1713 * if any (for instance a sigc::signal).
1714 * See https://bugzilla.gnome.org/show_bug.cgi?id=755003
1716 * The third overload is identical to do_visit_each() in visitor's primary template.
1720 template <typename T_return, typename T_arg1, typename T_arg2, typename T_arg3, typename T_arg4, typename T_arg5, typename T_arg6, typename T_arg7>
1721 struct visitor<slot<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>>
1723 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_bind>& _A_action,
1724 const slot<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1726 if (_A_target.rep_ && _A_target.rep_->parent_ == nullptr)
1727 _A_target.rep_->set_parent(_A_action.action_.rep_, &internal::slot_rep::notify);
1730 static void do_visit_each(const internal::limit_derived_target<trackable*, internal::slot_do_unbind>& _A_action,
1731 const slot<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1733 if (_A_target.rep_ && _A_target.rep_->parent_ == _A_action.action_.rep_)
1734 _A_target.rep_->set_parent(nullptr, nullptr);
1737 template <typename T_action>
1738 static void do_visit_each(const T_action& _A_action,
1739 const slot<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7>& _A_target)
1741 _A_action(_A_target);
1744 #endif // DOXYGEN_SHOULD_SKIP_THIS
1748 /** Convenience wrapper for the numbered sigc::slot0 template.
1749 * See the base class for useful methods.
1750 * This is the template specialization of the unnumbered sigc::slot
1751 * template for 0 argument(s), specialized for different numbers of arguments
1752 * This is possible because the template has default (nil) template types.
1754 * @deprecated Please use the syntax similar to that used by std::function<>:
1756 * sigc::slot<void(bool, int)> some_slot;
1760 template <class T_return>
1761 class slot <T_return, nil, nil, nil, nil, nil, nil, nil>
1762 : public slot0<T_return>
1765 typedef slot0<T_return> parent_type;
1769 /** Constructs a slot from an arbitrary functor.
1770 * @param _A_func The desired functor the new slot should be assigned to.
1772 template <class T_functor>
1773 slot(const T_functor& _A_func)
1774 : parent_type(_A_func) {}
1776 // Without static_cast parent_type(const T_functor& _A_func)
1777 // is called instead of the copy constructor.
1778 /** Constructs a slot, copying an existing one.
1779 * @param src The existing slot to copy.
1781 slot(const slot& src)
1782 : parent_type(static_cast<const parent_type&>(src)) {}
1784 // Without static_cast parent_type(const T_functor& _A_func)
1785 // is called instead of the move constructor.
1786 /** Constructs a slot, moving an existing one.
1787 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1788 * @param src The existing slot to move or copy.
1791 : parent_type(std::move(static_cast<parent_type&>(src))) {}
1793 /** Overrides this slot, making a copy from another slot.
1794 * @param src The slot from which to make a copy.
1797 slot& operator=(const slot& src)
1799 parent_type::operator=(src);
1803 /** Overrides this slot, making a move from another slot.
1804 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1805 * @param src The slot from which to move or copy.
1808 slot& operator=(slot&& src)
1810 parent_type::operator=(std::move(src));
1817 /** Convenience wrapper for the numbered sigc::slot1 template.
1818 * See the base class for useful methods.
1819 * This is the template specialization of the unnumbered sigc::slot
1820 * template for 1 argument(s), specialized for different numbers of arguments
1821 * This is possible because the template has default (nil) template types.
1823 * @deprecated Please use the syntax similar to that used by std::function<>:
1825 * sigc::slot<void(bool, int)> some_slot;
1829 template <class T_return, class T_arg1>
1830 class slot <T_return, T_arg1, nil, nil, nil, nil, nil, nil>
1831 : public slot1<T_return, T_arg1>
1834 typedef slot1<T_return, T_arg1> parent_type;
1838 /** Constructs a slot from an arbitrary functor.
1839 * @param _A_func The desired functor the new slot should be assigned to.
1841 template <class T_functor>
1842 slot(const T_functor& _A_func)
1843 : parent_type(_A_func) {}
1845 // Without static_cast parent_type(const T_functor& _A_func)
1846 // is called instead of the copy constructor.
1847 /** Constructs a slot, copying an existing one.
1848 * @param src The existing slot to copy.
1850 slot(const slot& src)
1851 : parent_type(static_cast<const parent_type&>(src)) {}
1853 // Without static_cast parent_type(const T_functor& _A_func)
1854 // is called instead of the move constructor.
1855 /** Constructs a slot, moving an existing one.
1856 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1857 * @param src The existing slot to move or copy.
1860 : parent_type(std::move(static_cast<parent_type&>(src))) {}
1862 /** Overrides this slot, making a copy from another slot.
1863 * @param src The slot from which to make a copy.
1866 slot& operator=(const slot& src)
1868 parent_type::operator=(src);
1872 /** Overrides this slot, making a move from another slot.
1873 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1874 * @param src The slot from which to move or copy.
1877 slot& operator=(slot&& src)
1879 parent_type::operator=(std::move(src));
1886 /** Convenience wrapper for the numbered sigc::slot2 template.
1887 * See the base class for useful methods.
1888 * This is the template specialization of the unnumbered sigc::slot
1889 * template for 2 argument(s), specialized for different numbers of arguments
1890 * This is possible because the template has default (nil) template types.
1892 * @deprecated Please use the syntax similar to that used by std::function<>:
1894 * sigc::slot<void(bool, int)> some_slot;
1898 template <class T_return, class T_arg1, class T_arg2>
1899 class slot <T_return, T_arg1, T_arg2, nil, nil, nil, nil, nil>
1900 : public slot2<T_return, T_arg1, T_arg2>
1903 typedef slot2<T_return, T_arg1, T_arg2> parent_type;
1907 /** Constructs a slot from an arbitrary functor.
1908 * @param _A_func The desired functor the new slot should be assigned to.
1910 template <class T_functor>
1911 slot(const T_functor& _A_func)
1912 : parent_type(_A_func) {}
1914 // Without static_cast parent_type(const T_functor& _A_func)
1915 // is called instead of the copy constructor.
1916 /** Constructs a slot, copying an existing one.
1917 * @param src The existing slot to copy.
1919 slot(const slot& src)
1920 : parent_type(static_cast<const parent_type&>(src)) {}
1922 // Without static_cast parent_type(const T_functor& _A_func)
1923 // is called instead of the move constructor.
1924 /** Constructs a slot, moving an existing one.
1925 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1926 * @param src The existing slot to move or copy.
1929 : parent_type(std::move(static_cast<parent_type&>(src))) {}
1931 /** Overrides this slot, making a copy from another slot.
1932 * @param src The slot from which to make a copy.
1935 slot& operator=(const slot& src)
1937 parent_type::operator=(src);
1941 /** Overrides this slot, making a move from another slot.
1942 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1943 * @param src The slot from which to move or copy.
1946 slot& operator=(slot&& src)
1948 parent_type::operator=(std::move(src));
1955 /** Convenience wrapper for the numbered sigc::slot3 template.
1956 * See the base class for useful methods.
1957 * This is the template specialization of the unnumbered sigc::slot
1958 * template for 3 argument(s), specialized for different numbers of arguments
1959 * This is possible because the template has default (nil) template types.
1961 * @deprecated Please use the syntax similar to that used by std::function<>:
1963 * sigc::slot<void(bool, int)> some_slot;
1967 template <class T_return, class T_arg1, class T_arg2, class T_arg3>
1968 class slot <T_return, T_arg1, T_arg2, T_arg3, nil, nil, nil, nil>
1969 : public slot3<T_return, T_arg1, T_arg2, T_arg3>
1972 typedef slot3<T_return, T_arg1, T_arg2, T_arg3> parent_type;
1976 /** Constructs a slot from an arbitrary functor.
1977 * @param _A_func The desired functor the new slot should be assigned to.
1979 template <class T_functor>
1980 slot(const T_functor& _A_func)
1981 : parent_type(_A_func) {}
1983 // Without static_cast parent_type(const T_functor& _A_func)
1984 // is called instead of the copy constructor.
1985 /** Constructs a slot, copying an existing one.
1986 * @param src The existing slot to copy.
1988 slot(const slot& src)
1989 : parent_type(static_cast<const parent_type&>(src)) {}
1991 // Without static_cast parent_type(const T_functor& _A_func)
1992 // is called instead of the move constructor.
1993 /** Constructs a slot, moving an existing one.
1994 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
1995 * @param src The existing slot to move or copy.
1998 : parent_type(std::move(static_cast<parent_type&>(src))) {}
2000 /** Overrides this slot, making a copy from another slot.
2001 * @param src The slot from which to make a copy.
2004 slot& operator=(const slot& src)
2006 parent_type::operator=(src);
2010 /** Overrides this slot, making a move from another slot.
2011 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2012 * @param src The slot from which to move or copy.
2015 slot& operator=(slot&& src)
2017 parent_type::operator=(std::move(src));
2024 /** Convenience wrapper for the numbered sigc::slot4 template.
2025 * See the base class for useful methods.
2026 * This is the template specialization of the unnumbered sigc::slot
2027 * template for 4 argument(s), specialized for different numbers of arguments
2028 * This is possible because the template has default (nil) template types.
2030 * @deprecated Please use the syntax similar to that used by std::function<>:
2032 * sigc::slot<void(bool, int)> some_slot;
2036 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4>
2037 class slot <T_return, T_arg1, T_arg2, T_arg3, T_arg4, nil, nil, nil>
2038 : public slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4>
2041 typedef slot4<T_return, T_arg1, T_arg2, T_arg3, T_arg4> parent_type;
2045 /** Constructs a slot from an arbitrary functor.
2046 * @param _A_func The desired functor the new slot should be assigned to.
2048 template <class T_functor>
2049 slot(const T_functor& _A_func)
2050 : parent_type(_A_func) {}
2052 // Without static_cast parent_type(const T_functor& _A_func)
2053 // is called instead of the copy constructor.
2054 /** Constructs a slot, copying an existing one.
2055 * @param src The existing slot to copy.
2057 slot(const slot& src)
2058 : parent_type(static_cast<const parent_type&>(src)) {}
2060 // Without static_cast parent_type(const T_functor& _A_func)
2061 // is called instead of the move constructor.
2062 /** Constructs a slot, moving an existing one.
2063 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2064 * @param src The existing slot to move or copy.
2067 : parent_type(std::move(static_cast<parent_type&>(src))) {}
2069 /** Overrides this slot, making a copy from another slot.
2070 * @param src The slot from which to make a copy.
2073 slot& operator=(const slot& src)
2075 parent_type::operator=(src);
2079 /** Overrides this slot, making a move from another slot.
2080 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2081 * @param src The slot from which to move or copy.
2084 slot& operator=(slot&& src)
2086 parent_type::operator=(std::move(src));
2093 /** Convenience wrapper for the numbered sigc::slot5 template.
2094 * See the base class for useful methods.
2095 * This is the template specialization of the unnumbered sigc::slot
2096 * template for 5 argument(s), specialized for different numbers of arguments
2097 * This is possible because the template has default (nil) template types.
2099 * @deprecated Please use the syntax similar to that used by std::function<>:
2101 * sigc::slot<void(bool, int)> some_slot;
2105 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5>
2106 class slot <T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, nil, nil>
2107 : public slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5>
2110 typedef slot5<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5> parent_type;
2114 /** Constructs a slot from an arbitrary functor.
2115 * @param _A_func The desired functor the new slot should be assigned to.
2117 template <class T_functor>
2118 slot(const T_functor& _A_func)
2119 : parent_type(_A_func) {}
2121 // Without static_cast parent_type(const T_functor& _A_func)
2122 // is called instead of the copy constructor.
2123 /** Constructs a slot, copying an existing one.
2124 * @param src The existing slot to copy.
2126 slot(const slot& src)
2127 : parent_type(static_cast<const parent_type&>(src)) {}
2129 // Without static_cast parent_type(const T_functor& _A_func)
2130 // is called instead of the move constructor.
2131 /** Constructs a slot, moving an existing one.
2132 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2133 * @param src The existing slot to move or copy.
2136 : parent_type(std::move(static_cast<parent_type&>(src))) {}
2138 /** Overrides this slot, making a copy from another slot.
2139 * @param src The slot from which to make a copy.
2142 slot& operator=(const slot& src)
2144 parent_type::operator=(src);
2148 /** Overrides this slot, making a move from another slot.
2149 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2150 * @param src The slot from which to move or copy.
2153 slot& operator=(slot&& src)
2155 parent_type::operator=(std::move(src));
2162 /** Convenience wrapper for the numbered sigc::slot6 template.
2163 * See the base class for useful methods.
2164 * This is the template specialization of the unnumbered sigc::slot
2165 * template for 6 argument(s), specialized for different numbers of arguments
2166 * This is possible because the template has default (nil) template types.
2168 * @deprecated Please use the syntax similar to that used by std::function<>:
2170 * sigc::slot<void(bool, int)> some_slot;
2174 template <class T_return, class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6>
2175 class slot <T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, nil>
2176 : public slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6>
2179 typedef slot6<T_return, T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6> parent_type;
2183 /** Constructs a slot from an arbitrary functor.
2184 * @param _A_func The desired functor the new slot should be assigned to.
2186 template <class T_functor>
2187 slot(const T_functor& _A_func)
2188 : parent_type(_A_func) {}
2190 // Without static_cast parent_type(const T_functor& _A_func)
2191 // is called instead of the copy constructor.
2192 /** Constructs a slot, copying an existing one.
2193 * @param src The existing slot to copy.
2195 slot(const slot& src)
2196 : parent_type(static_cast<const parent_type&>(src)) {}
2198 // Without static_cast parent_type(const T_functor& _A_func)
2199 // is called instead of the move constructor.
2200 /** Constructs a slot, moving an existing one.
2201 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2202 * @param src The existing slot to move or copy.
2205 : parent_type(std::move(static_cast<parent_type&>(src))) {}
2207 /** Overrides this slot, making a copy from another slot.
2208 * @param src The slot from which to make a copy.
2211 slot& operator=(const slot& src)
2213 parent_type::operator=(src);
2217 /** Overrides this slot, making a move from another slot.
2218 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2219 * @param src The slot from which to move or copy.
2222 slot& operator=(slot&& src)
2224 parent_type::operator=(std::move(src));
2232 /** Converts an arbitrary functor to a unified type which is opaque.
2233 * sigc::slot itself is a functor or, to be more precise, a closure. It contains
2234 * a single, arbitrary functor (or closure) that is executed in operator()().
2236 * The template arguments determine the function signature of operator()():
2237 * - @e T_return The return type of operator()().
2238 * - @e T_arg Argument types used in the definition of operator()().
2240 * For instance, to declare a slot that returns void and takes two parameters
2243 * sigc::slot<void(bool, int)> some_slot;
2246 * Alternatively, you may use this syntax:
2248 * sigc::slot<void, bool, int> some_slot;
2251 * To use, simply assign the desired functor to the slot. If the functor
2252 * is not compatible with the parameter list defined with the template
2253 * arguments then compiler errors are triggered. When called, the slot
2254 * will invoke the functor with minimal copies.
2255 * block() and unblock() can be used to block the functor's invocation
2256 * from operator()() temporarily.
2260 template <class T_return, class... T_arg>
2261 class slot<T_return(T_arg...)>
2265 using result_type = T_return;
2266 //TODO: using arg_type_ = type_trait_take_t<T_arg>;
2268 #ifndef DOXYGEN_SHOULD_SKIP_THIS
2270 using rep_type = internal::slot_rep;
2272 using call_type = T_return (*)(rep_type*, type_trait_take_t<T_arg>...);
2275 /** Invoke the contained functor unless slot is in blocking state.
2276 * @param _A_a Arguments to be passed on to the functor.
2277 * @return The return value of the functor invocation.
2279 inline T_return operator()(type_trait_take_t<T_arg>... _A_a) const
2281 if (!empty() && !blocked())
2282 return (sigc::internal::function_pointer_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, _A_a...);
2288 /** Constructs a slot from an arbitrary functor.
2289 * @param _A_func The desired functor the new slot should be assigned to.
2291 template <class T_functor>
2292 slot(const T_functor& _A_func)
2293 : slot_base(new internal::typed_slot_rep<T_functor>(_A_func))
2295 //The slot_base:: is necessary to stop the HP-UX aCC compiler from being confused. murrayc.
2296 slot_base::rep_->call_ = internal::slot_call<T_functor, T_return, T_arg...>::address();
2299 /** Constructs a slot, copying an existing one.
2300 * @param src The existing slot to copy.
2302 slot(const slot& src)
2306 /** Constructs a slot, moving an existing one.
2307 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2308 * @param src The existing slot to move or copy.
2311 : slot_base(std::move(src))
2314 /** Overrides this slot, making a copy from another slot.
2315 * @param src The slot from which to make a copy.
2318 slot& operator=(const slot& src)
2320 slot_base::operator=(src);
2324 /** Overrides this slot, making a move from another slot.
2325 * If @p src is connected to a parent (e.g. a signal), it is copied, not moved.
2326 * @param src The slot from which to move or copy.
2329 slot& operator=(slot&& src)
2331 slot_base::operator=(std::move(src));
2336 } /* namespace sigc */
2338 #ifdef SIGC_NIL_HAS_BEEN_PUSHED
2339 #undef SIGC_NIL_HAS_BEEN_PUSHED
2340 #pragma pop_macro("nil")
2342 #endif /* _SIGC_FUNCTORS_SLOT_H_ */