@@ -374,14 +374,14 @@ struct signal_emit<void, void, T_arg...>
374
374
/* * Signal declaration.
375
375
* %signal_with_accumulator can be used to connect() slots that are invoked
376
376
* during subsequent calls to emit(). Any functor or slot
377
- * can be passed into connect(). It is converted into a slot
377
+ * can be passed into connect() or connect_first() . It is converted into a slot
378
378
* implicitly.
379
379
*
380
380
* If you want to connect one signal to another, use make_slot()
381
381
* to retrieve a functor that emits the signal when invoked.
382
382
*
383
- * Be careful if you directly pass one signal into the connect()
384
- * method of another: a shallow copy of the signal is made and
383
+ * Be careful if you directly pass one signal into the connect() or
384
+ * connect_first() method of another: a shallow copy of the signal is made and
385
385
* the signal's slots are not disconnected until both the signal
386
386
* and its clone are destroyed, which is probably not what you want!
387
387
*
@@ -401,8 +401,8 @@ class signal_with_accumulator : public signal_base
401
401
public:
402
402
using slot_type = slot<T_return(T_arg...)>;
403
403
404
- /* * Add a slot to the list of slots.
405
- * Any functor or slot may be passed into connect().
404
+ /* * Add a slot at the end of the list of slots.
405
+ * Any functor or slot may be passed into % connect().
406
406
* It will be converted into a slot implicitly.
407
407
* The returned connection may be stored for disconnection
408
408
* of the slot at some later point. It stays valid until
@@ -426,7 +426,7 @@ class signal_with_accumulator : public signal_base
426
426
return connection (slot_base);
427
427
}
428
428
429
- /* * Add a slot to the list of slots.
429
+ /* * Add a slot at the end of the list of slots.
430
430
* @see connect(const slot_type& slot_).
431
431
*
432
432
* @newin{2,8}
@@ -438,6 +438,45 @@ class signal_with_accumulator : public signal_base
438
438
return connection (slot_base);
439
439
}
440
440
441
+ /* * Add a slot at the beginning of the list of slots.
442
+ * Any functor or slot may be passed into %connect_first().
443
+ * It will be converted into a slot implicitly.
444
+ * The returned connection may be stored for disconnection
445
+ * of the slot at some later point. It stays valid until
446
+ * the slot is disconnected from the signal.
447
+ * std::function<> and C++11 lambda expressions are functors.
448
+ * These are examples of functors that can be connected to a signal.
449
+ *
450
+ * %std::bind() creates a functor, but this functor typically has an
451
+ * %operator()() which is a variadic template.
452
+ * Our functor_trait can't deduce the result type
453
+ * of such a functor. If you first assign the return value of %std::bind()
454
+ * to a std::function, you can connect the std::function to a signal.
455
+ *
456
+ * @param slot_ The slot to add to the list of slots.
457
+ * @return A connection.
458
+ *
459
+ * @newin{3,6}
460
+ */
461
+ connection connect_first (const slot_type& slot_)
462
+ {
463
+ auto iter = signal_base::connect_first (slot_);
464
+ auto & slot_base = *iter;
465
+ return connection (slot_base);
466
+ }
467
+
468
+ /* * Add a slot at the beginning of the list of slots.
469
+ * @see connect_first(const slot_type& slot_).
470
+ *
471
+ * @newin{3,6}
472
+ */
473
+ connection connect_first (slot_type&& slot_)
474
+ {
475
+ auto iter = signal_base::connect_first (std::move (slot_));
476
+ auto & slot_base = *iter;
477
+ return connection (slot_base);
478
+ }
479
+
441
480
/* * Triggers the emission of the signal.
442
481
* During signal emission all slots that have been connected
443
482
* to the signal are invoked unless they are manually set into
@@ -505,14 +544,14 @@ class signal_with_accumulator : public signal_base
505
544
506
545
/* * signal can be used to connect() slots that are invoked
507
546
* during subsequent calls to emit(). Any functor or slot
508
- * can be passed into connect(). It is converted into a slot
547
+ * can be passed into connect() or connect_first() . It is converted into a slot
509
548
* implicitly.
510
549
*
511
550
* If you want to connect one signal to another, use make_slot()
512
551
* to retrieve a functor that emits the signal when invoked.
513
552
*
514
- * Be careful if you directly pass one signal into the connect()
515
- * method of another: a shallow copy of the signal is made and
553
+ * Be careful if you directly pass one signal into the connect() or
554
+ * connect_first() method of another: a shallow copy of the signal is made and
516
555
* the signal's slots are not disconnected until both the signal
517
556
* and its clone are destroyed, which is probably not what you want!
518
557
*
@@ -634,13 +673,14 @@ class signal<T_return(T_arg...)> : public signal_with_accumulator<T_return, void
634
673
/* * Signal declaration.
635
674
* %trackable_signal_with_accumulator can be used to connect() slots that are invoked
636
675
* during subsequent calls to emit(). Any functor or slot
637
- * can be passed into connect(). It is converted into a slot implicitly.
676
+ * can be passed into connect() or connect_first(). It is converted into a slot
677
+ * implicitly.
638
678
*
639
679
* If you want to connect one signal to another, use make_slot()
640
680
* to retrieve a functor that emits the signal when invoked.
641
681
*
642
- * Be careful if you directly pass one signal into the connect()
643
- * method of another: a shallow copy of the signal is made and
682
+ * Be careful if you directly pass one signal into the connect() or
683
+ * connect_first() method of another: a shallow copy of the signal is made and
644
684
* the signal's slots are not disconnected until both the signal
645
685
* and its clone are destroyed, which is probably not what you want!
646
686
*
@@ -664,8 +704,8 @@ class trackable_signal_with_accumulator
664
704
public:
665
705
using slot_type = slot<T_return(T_arg...)>;
666
706
667
- /* * Add a slot to the list of slots.
668
- * Any functor or slot may be passed into connect().
707
+ /* * Add a slot at the end of the list of slots.
708
+ * Any functor or slot may be passed into % connect().
669
709
* It will be converted into a slot implicitly.
670
710
* The returned connection may be stored for disconnection
671
711
* of the slot at some later point. It stays valid until
@@ -689,7 +729,7 @@ class trackable_signal_with_accumulator
689
729
return connection (slot_base);
690
730
}
691
731
692
- /* * Add a slot to the list of slots.
732
+ /* * Add a slot at the end of the list of slots.
693
733
* @see connect(const slot_type& slot_).
694
734
*/
695
735
connection connect (slot_type&& slot_)
@@ -699,6 +739,45 @@ class trackable_signal_with_accumulator
699
739
return connection (slot_base);
700
740
}
701
741
742
+ /* * Add a slot at the beginning of the list of slots.
743
+ * Any functor or slot may be passed into %connect_first().
744
+ * It will be converted into a slot implicitly.
745
+ * The returned connection may be stored for disconnection
746
+ * of the slot at some later point. It stays valid until
747
+ * the slot is disconnected from the signal.
748
+ * std::function<> and C++11 lambda expressions are functors.
749
+ * These are examples of functors that can be connected to a signal.
750
+ *
751
+ * %std::bind() creates a functor, but this functor typically has an
752
+ * %operator()() which is a variadic template.
753
+ * Our functor_trait can't deduce the result type
754
+ * of such a functor. If you first assign the return value of %std::bind()
755
+ * to a std::function, you can connect the std::function to a signal.
756
+ *
757
+ * @param slot_ The slot to add to the list of slots.
758
+ * @return A connection.
759
+ *
760
+ * @newin{3,6}
761
+ */
762
+ connection connect_first (const slot_type& slot_)
763
+ {
764
+ auto iter = signal_base::connect_first (slot_);
765
+ auto & slot_base = *iter;
766
+ return connection (slot_base);
767
+ }
768
+
769
+ /* * Add a slot at the beginning of the list of slots.
770
+ * @see connect_first(const slot_type& slot_).
771
+ *
772
+ * @newin{3,6}
773
+ */
774
+ connection connect_first (slot_type&& slot_)
775
+ {
776
+ auto iter = signal_base::connect_first (std::move (slot_));
777
+ auto & slot_base = *iter;
778
+ return connection (slot_base);
779
+ }
780
+
702
781
/* * Triggers the emission of the signal.
703
782
* During signal emission all slots that have been connected
704
783
* to the signal are invoked unless they are manually set into
@@ -772,14 +851,14 @@ class trackable_signal_with_accumulator
772
851
773
852
/* * %trackable_signal can be used to connect() slots that are invoked
774
853
* during subsequent calls to emit(). Any functor or slot
775
- * can be passed into connect(). It is converted into a slot
854
+ * can be passed into connect() or connect_first() . It is converted into a slot
776
855
* implicitly.
777
856
*
778
857
* If you want to connect one signal to another, use make_slot()
779
858
* to retrieve a functor that emits the signal when invoked.
780
859
*
781
- * Be careful if you directly pass one signal into the connect()
782
- * method of another: a shallow copy of the signal is made and
860
+ * Be careful if you directly pass one signal into the connect() or
861
+ * connect_first() method of another: a shallow copy of the signal is made and
783
862
* the signal's slots are not disconnected until both the signal
784
863
* and its clone are destroyed, which is probably not what you want!
785
864
*
0 commit comments