From fe412ea187ac6762ac48b0caf2c5bd873f6b9d76 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 20 Nov 2015 22:18:10 +0100 Subject: Use range based for loops. --- plugingui/notifier.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'plugingui') diff --git a/plugingui/notifier.h b/plugingui/notifier.h index 57ca453..328ab7d 100644 --- a/plugingui/notifier.h +++ b/plugingui/notifier.h @@ -84,8 +84,9 @@ class Listener { public: virtual ~Listener() { - for(auto signal = signals.begin(); signal != signals.end(); ++signal) { - (*signal)->disconnect(this); + for(auto signal : signals) + { + signal->disconnect(this); } } @@ -111,8 +112,9 @@ public: //! \brief When dtor is called it will automatically disconnect all its listeners. ~Notifier() { - for(auto slot = slots.begin(); slot != slots.end(); ++slot) { - (*slot).first->unregisterNotifier(this); + for(auto& slot : slots) + { + slot.first->unregisterNotifier(this); } } @@ -123,7 +125,8 @@ public: void connect(O* p, const F& fn) { slots[p] = std::move(construct_mem_fn(fn, p, aux::gen_int_sequence{})); - if(p && dynamic_cast(p)) { + if(p && dynamic_cast(p)) + { dynamic_cast(p)->registerNotifier(this); } } @@ -138,8 +141,9 @@ public: //! Example: Notifier foo; foo(42); void operator()(Args... args) { - for(auto slot = slots.begin(); slot != slots.end(); ++slot) { - (*slot).second(args...); + for(auto& slot : slots) + { + slot.second(args...); } } -- cgit v1.2.3