33
33
namespace sigc
34
34
{
35
35
36
- /* * STL-style iterator for slot_list.
37
- *
38
- * @ingroup signal
39
- */
40
- template <typename T_slot>
41
- struct slot_iterator
42
- {
43
- using size_type = std::size_t ;
44
- using difference_type = std::ptrdiff_t ;
45
- using iterator_category = std::bidirectional_iterator_tag;
46
-
47
- using slot_type = T_slot;
48
-
49
- using value_type = T_slot;
50
- using pointer = T_slot*;
51
- using reference = T_slot&;
52
-
53
- using iterator_type = typename internal::signal_impl::iterator_type;
54
-
55
- slot_iterator () = default ;
56
-
57
- explicit slot_iterator (const iterator_type& i) : i_(i) {}
58
-
59
- reference operator *() const { return static_cast <reference>(*i_); }
60
-
61
- pointer operator ->() const { return &(operator *()); }
62
-
63
- slot_iterator& operator ++()
64
- {
65
- ++i_;
66
- return *this ;
67
- }
68
-
69
- slot_iterator operator ++(int )
70
- {
71
- slot_iterator tmp (*this );
72
- ++i_;
73
- return tmp;
74
- }
75
-
76
- slot_iterator& operator --()
77
- {
78
- --i_;
79
- return *this ;
80
- }
81
-
82
- slot_iterator operator --(int )
83
- {
84
- slot_iterator tmp (*this );
85
- --i_;
86
- return tmp;
87
- }
88
-
89
- bool operator ==(const slot_iterator& other) const { return i_ == other.i_ ; }
90
-
91
- bool operator !=(const slot_iterator& other) const { return i_ != other.i_ ; }
92
-
93
- iterator_type i_;
94
- };
95
-
96
36
namespace internal
97
37
{
98
38
@@ -471,21 +411,12 @@ class signal_with_accumulator : public signal_base
471
411
public:
472
412
using slot_type = slot<T_return(T_arg...)>;
473
413
474
- private:
475
- using iterator = slot_iterator<slot_type>;
476
-
477
- public:
478
-
479
-
480
414
/* * Add a slot to the list of slots.
481
415
* Any functor or slot may be passed into connect().
482
416
* It will be converted into a slot implicitly.
483
- * The returned iterator may be stored for disconnection
417
+ * The returned connection may be stored for disconnection
484
418
* of the slot at some later point. It stays valid until
485
- * the slot is removed from the list of slots. The iterator
486
- * can also be implicitly converted into a sigc::connection object
487
- * that may be used safely beyond the life time of the slot.
488
- *
419
+ * the slot is disconnected from the signal.
489
420
* std::function<> and C++11 lambda expressions are functors.
490
421
* These are examples of functors that can be connected to a signal.
491
422
*
@@ -496,11 +427,13 @@ class signal_with_accumulator : public signal_base
496
427
* to a std::function, you can connect the std::function to a signal.
497
428
*
498
429
* @param slot_ The slot to add to the list of slots.
499
- * @return An iterator pointing to the new slot in the list .
430
+ * @return A connection .
500
431
*/
501
432
connection connect (const slot_type& slot_)
502
433
{
503
- return connection (iterator (signal_base::connect (slot_)));
434
+ auto iter = signal_base::connect (slot_);
435
+ auto & slot_base = *iter;
436
+ return connection (&slot_base);
504
437
}
505
438
506
439
/* * Add a slot to the list of slots.
@@ -510,7 +443,9 @@ class signal_with_accumulator : public signal_base
510
443
*/
511
444
connection connect (slot_type&& slot_)
512
445
{
513
- return connection (iterator (signal_base::connect (std::move (slot_))));
446
+ auto iter = signal_base::connect (std::move (slot_));
447
+ auto & slot_base = *iter;
448
+ return connection (&slot_base);
514
449
}
515
450
516
451
/* * Triggers the emission of the signal.
0 commit comments