Skip to content

Commit 6ad9036

Browse files
author
Kjell Ahlstedt
committed
trackable, slot_base, signal_base, connection: Add some noexcept specs
1 parent 18a9f6d commit 6ad9036

File tree

8 files changed

+63
-62
lines changed

8 files changed

+63
-62
lines changed

sigc++/connection.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace std;
2222

2323
namespace sigc {
2424

25-
connection::connection()
25+
connection::connection() noexcept
2626
: slot_(nullptr)
2727
{}
2828

@@ -53,27 +53,27 @@ connection::~connection()
5353
slot_->remove_destroy_notify_callback(this);
5454
}
5555

56-
bool connection::empty() const
56+
bool connection::empty() const noexcept
5757
{
5858
return (!slot_ || slot_->empty());
5959
}
6060

61-
bool connection::connected() const
61+
bool connection::connected() const noexcept
6262
{
6363
return !empty();
6464
}
6565

66-
bool connection::blocked() const
66+
bool connection::blocked() const noexcept
6767
{
6868
return (slot_ ? slot_->blocked() : false);
6969
}
7070

71-
bool connection::block(bool should_block)
71+
bool connection::block(bool should_block) noexcept
7272
{
7373
return (slot_ ? slot_->block(should_block) : false);
7474
}
7575

76-
bool connection::unblock()
76+
bool connection::unblock() noexcept
7777
{
7878
return (slot_ ? slot_->unblock() : false);
7979
}
@@ -84,7 +84,7 @@ void connection::disconnect()
8484
slot_->disconnect(); // This notifies slot_'s parent.
8585
}
8686

87-
connection::operator bool()
87+
connection::operator bool() noexcept
8888
{
8989
return !empty();
9090
}

sigc++/connection.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace sigc {
4040
struct SIGC_API connection
4141
{
4242
/** Constructs an empty connection object. */
43-
connection();
43+
connection() noexcept;
4444

4545
/** Constructs a connection object copying an existing one.
4646
* @param c The connection object to make a copy from.
@@ -77,37 +77,38 @@ struct SIGC_API connection
7777
/** Returns whether the connection is still active.
7878
* @return @p false if the connection is still active.
7979
*/
80-
bool empty() const;
80+
bool empty() const noexcept;
8181

8282
/** Returns whether the connection is still active.
8383
* @return @p true if the connection is still active.
8484
*/
85-
bool connected() const;
85+
bool connected() const noexcept;
8686

8787
/** Returns whether the connection is blocked.
8888
* @return @p true if the connection is blocked.
8989
*/
90-
bool blocked() const;
90+
bool blocked() const noexcept;
9191

9292
/** Sets or unsets the blocking state of this connection.
9393
* See slot_base::block() for details.
9494
* @param should_block Indicates whether the blocking state should be set or unset.
9595
* @return @p true if the connection has been in blocking state before.
9696
*/
97-
bool block(bool should_block = true);
97+
bool block(bool should_block = true) noexcept;
9898

9999
/** Unsets the blocking state of this connection.
100100
* @return @p true if the connection has been in blocking state before.
101101
*/
102-
bool unblock();
102+
bool unblock() noexcept;
103103

104104
/// Disconnects the referred slot.
105105
void disconnect();
106106

107+
//TODO: When we can break API and ABI, make operator bool() explicit and const
107108
/** Returns whether the connection is still active.
108109
* @return @p true if the connection is still active.
109110
*/
110-
operator bool();
111+
operator bool() noexcept;
111112

112113
/** Callback that is executed when the referred slot is destroyed.
113114
* @param data The connection object notified (@p this).

sigc++/functors/slot_base.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ namespace
2525
// notified, if the slot_rep is deleted when they call disconnect().
2626
struct destroy_notify_struct
2727
{
28-
destroy_notify_struct() : deleted_(false) { }
28+
destroy_notify_struct() noexcept : deleted_(false) { }
2929

30-
static void* notify(void* data)
30+
static void* notify(void* data) noexcept
3131
{
3232
auto self_ = reinterpret_cast<destroy_notify_struct*>(data);
3333
self_->deleted_ = true;
@@ -96,12 +96,12 @@ void* slot_rep::notify(void* data)
9696

9797
} // namespace internal
9898

99-
slot_base::slot_base()
99+
slot_base::slot_base() noexcept
100100
: rep_(nullptr),
101101
blocked_(false)
102102
{}
103103

104-
slot_base::slot_base(rep_type* rep)
104+
slot_base::slot_base(rep_type* rep) noexcept
105105
: rep_(rep),
106106
blocked_(false)
107107
{}
@@ -162,7 +162,7 @@ slot_base::~slot_base()
162162
delete rep_;
163163
}
164164

165-
slot_base::operator bool() const
165+
slot_base::operator bool() const noexcept
166166
{
167167
return rep_ != nullptr;
168168
}
@@ -261,7 +261,7 @@ slot_base& slot_base::operator=(slot_base&& src)
261261
return *this;
262262
}
263263

264-
void slot_base::set_parent(void* parent, void* (*cleanup)(void*)) const
264+
void slot_base::set_parent(void* parent, void* (*cleanup)(void*)) const noexcept
265265
{
266266
if (rep_)
267267
rep_->set_parent(parent, cleanup);
@@ -279,14 +279,14 @@ void slot_base::remove_destroy_notify_callback(void* data) const
279279
rep_->remove_destroy_notify_callback(data);
280280
}
281281

282-
bool slot_base::block(bool should_block)
282+
bool slot_base::block(bool should_block) noexcept
283283
{
284284
bool old = blocked_;
285285
blocked_ = should_block;
286286
return old;
287287
}
288288

289-
bool slot_base::unblock()
289+
bool slot_base::unblock() noexcept
290290
{
291291
return block(false);
292292
}

sigc++/functors/slot_base.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct SIGC_API slot_rep : public trackable
8888
/** Parent object whose callback cleanup_ is executed on notification. */
8989
void* parent_;
9090

91-
inline slot_rep(hook call__, hook destroy__, hook dup__)
91+
inline slot_rep(hook call__, hook destroy__, hook dup__) noexcept
9292
: call_(call__), destroy_(destroy__), dup_(dup__), cleanup_(nullptr), parent_(nullptr) {}
9393

9494
inline ~slot_rep()
@@ -116,7 +116,7 @@ struct SIGC_API slot_rep : public trackable
116116
* @param parent The new parent.
117117
* @param cleanup The callback to execute from notify().
118118
*/
119-
inline void set_parent(void* parent, hook cleanup)
119+
inline void set_parent(void* parent, hook cleanup) noexcept
120120
{
121121
parent_ = parent;
122122
cleanup_ = cleanup;
@@ -147,7 +147,7 @@ struct SIGC_API slot_do_bind
147147
/** Construct a slot_do_bind functor.
148148
* @param rep The slot_rep object trackables should notify on destruction.
149149
*/
150-
inline slot_do_bind(slot_rep* rep) : rep_(rep) {}
150+
inline slot_do_bind(slot_rep* rep) noexcept : rep_(rep) {}
151151

152152
/** Adds a dependency to @p t.
153153
* @param t The trackable object to add a callback to.
@@ -165,7 +165,7 @@ struct SIGC_API slot_do_unbind
165165
/** Construct a slot_do_unbind functor.
166166
* @param rep The slot_rep object trackables don't need to notify on destruction any more.
167167
*/
168-
inline slot_do_unbind(slot_rep* rep) : rep_(rep) {}
168+
inline slot_do_unbind(slot_rep* rep) noexcept : rep_(rep) {}
169169

170170
/** Removes a dependency from @p t.
171171
* @param t The trackable object to remove the callback from.
@@ -250,12 +250,12 @@ class SIGC_API slot_base : public functor_base
250250
// may throw an exception.
251251
public:
252252
/// Constructs an empty slot.
253-
slot_base();
253+
slot_base() noexcept;
254254

255255
/** Constructs a slot from an existing slot_rep object.
256256
* @param rep The slot_rep object this slot should contain.
257257
*/
258-
explicit slot_base(rep_type* rep);
258+
explicit slot_base(rep_type* rep) noexcept;
259259

260260
/** Constructs a slot, copying an existing one.
261261
* @param src The existing slot to copy.
@@ -277,7 +277,7 @@ class SIGC_API slot_base : public functor_base
277277
* do_something()
278278
* @endcode
279279
*/
280-
operator bool() const;
280+
operator bool() const noexcept;
281281

282282
/** Sets the parent of this slot.
283283
* This function is used by signals to register a notification callback.
@@ -286,7 +286,7 @@ class SIGC_API slot_base : public functor_base
286286
* @param parent The new parent.
287287
* @param cleanup The notification callback.
288288
*/
289-
void set_parent(void* parent, void* (*cleanup)(void*)) const;
289+
void set_parent(void* parent, void* (*cleanup)(void*)) const noexcept;
290290

291291
typedef trackable::func_destroy_notify func_destroy_notify;
292292
/** Add a callback that is executed (notified) when the slot is detroyed.
@@ -305,13 +305,13 @@ class SIGC_API slot_base : public functor_base
305305
/** Returns whether the slot is invalid.
306306
* @return @p true if the slot is invalid (empty).
307307
*/
308-
inline bool empty() const
308+
inline bool empty() const noexcept
309309
{ return (!rep_ || !rep_->call_); }
310310

311311
/** Returns whether the slot is blocked.
312312
* @return @p true if the slot is blocked.
313313
*/
314-
inline bool blocked() const
314+
inline bool blocked() const noexcept
315315
{ return blocked_; }
316316

317317
/** Sets the blocking state.
@@ -322,12 +322,12 @@ class SIGC_API slot_base : public functor_base
322322
* @param should_block Indicates whether the blocking state should be set or unset.
323323
* @return @p true if the slot was in blocking state before.
324324
*/
325-
bool block(bool should_block = true);
325+
bool block(bool should_block = true) noexcept;
326326

327327
/** Unsets the blocking state.
328328
* @return @p true if the slot was in blocking state before.
329329
*/
330-
bool unblock();
330+
bool unblock() noexcept;
331331

332332
/** Disconnects the slot.
333333
* Invalidates the slot and notifies the parent.

sigc++/signal_base.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ void signal_impl::clear()
6767
slots_.clear();
6868
}
6969

70-
signal_impl::size_type signal_impl::size() const
70+
signal_impl::size_type signal_impl::size() const noexcept
7171
{
7272
return slots_.size();
7373
}
7474

75-
bool signal_impl::blocked() const
75+
bool signal_impl::blocked() const noexcept
7676
{
7777
for (const auto& slot : const_cast<const std::list<slot_base>&>(slots_))
7878
{
@@ -82,7 +82,7 @@ bool signal_impl::blocked() const
8282
return true;
8383
}
8484

85-
void signal_impl::block(bool should_block)
85+
void signal_impl::block(bool should_block) noexcept
8686
{
8787
for (auto& slot : slots_)
8888
{
@@ -156,11 +156,11 @@ void* signal_impl::notify(void* d)
156156

157157
} /* namespace internal */
158158

159-
signal_base::signal_base()
159+
signal_base::signal_base() noexcept
160160
: impl_(nullptr)
161161
{}
162162

163-
signal_base::signal_base(const signal_base& src)
163+
signal_base::signal_base(const signal_base& src) noexcept
164164
: trackable(),
165165
impl_(src.impl())
166166
{
@@ -193,23 +193,23 @@ void signal_base::clear()
193193
impl_->clear();
194194
}
195195

196-
signal_base::size_type signal_base::size() const
196+
signal_base::size_type signal_base::size() const noexcept
197197
{
198198
return (impl_ ? impl_->size() : 0);
199199
}
200200

201-
bool signal_base::blocked() const
201+
bool signal_base::blocked() const noexcept
202202
{
203203
return (impl_ ? impl_->blocked() : true);
204204
}
205205

206-
void signal_base::block(bool should_block)
206+
void signal_base::block(bool should_block) noexcept
207207
{
208208
if (impl_)
209209
impl_->block(should_block);
210210
}
211211

212-
void signal_base::unblock()
212+
void signal_base::unblock() noexcept
213213
{
214214
if (impl_)
215215
impl_->block(false);

0 commit comments

Comments
 (0)