summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2015-11-10 09:46:50 +0100
committerKjell Ahlstedt <kjell.ahlstedt@bredband.net>2015-11-10 09:46:50 +0100
commit6ad9036bc8e926caba173b256dfe0705b7c7b873 (patch)
treeabe4bbb6c7bf46304c64058e7444328660dce6a4
parent18a9f6dce1793ca1f0c3f30add5308b870e92497 (diff)
downloadsigc++-6ad9036bc8e926caba173b256dfe0705b7c7b873.tar.gz
trackable, slot_base, signal_base, connection: Add some noexcept specs
-rw-r--r--sigc++/connection.cc14
-rw-r--r--sigc++/connection.h15
-rw-r--r--sigc++/functors/slot_base.cc16
-rw-r--r--sigc++/functors/slot_base.h24
-rw-r--r--sigc++/signal_base.cc18
-rw-r--r--sigc++/signal_base.h28
-rw-r--r--sigc++/trackable.cc4
-rw-r--r--sigc++/trackable.h6
8 files changed, 63 insertions, 62 deletions
diff --git a/sigc++/connection.cc b/sigc++/connection.cc
index e01bde0..91ee4ee 100644
--- a/sigc++/connection.cc
+++ b/sigc++/connection.cc
@@ -22,7 +22,7 @@ using namespace std;
namespace sigc {
-connection::connection()
+connection::connection() noexcept
: slot_(nullptr)
{}
@@ -53,27 +53,27 @@ connection::~connection()
slot_->remove_destroy_notify_callback(this);
}
-bool connection::empty() const
+bool connection::empty() const noexcept
{
return (!slot_ || slot_->empty());
}
-bool connection::connected() const
+bool connection::connected() const noexcept
{
return !empty();
}
-bool connection::blocked() const
+bool connection::blocked() const noexcept
{
return (slot_ ? slot_->blocked() : false);
}
-bool connection::block(bool should_block)
+bool connection::block(bool should_block) noexcept
{
return (slot_ ? slot_->block(should_block) : false);
}
-bool connection::unblock()
+bool connection::unblock() noexcept
{
return (slot_ ? slot_->unblock() : false);
}
@@ -84,7 +84,7 @@ void connection::disconnect()
slot_->disconnect(); // This notifies slot_'s parent.
}
-connection::operator bool()
+connection::operator bool() noexcept
{
return !empty();
}
diff --git a/sigc++/connection.h b/sigc++/connection.h
index 348afe9..2405876 100644
--- a/sigc++/connection.h
+++ b/sigc++/connection.h
@@ -40,7 +40,7 @@ namespace sigc {
struct SIGC_API connection
{
/** Constructs an empty connection object. */
- connection();
+ connection() noexcept;
/** Constructs a connection object copying an existing one.
* @param c The connection object to make a copy from.
@@ -77,37 +77,38 @@ struct SIGC_API connection
/** Returns whether the connection is still active.
* @return @p false if the connection is still active.
*/
- bool empty() const;
+ bool empty() const noexcept;
/** Returns whether the connection is still active.
* @return @p true if the connection is still active.
*/
- bool connected() const;
+ bool connected() const noexcept;
/** Returns whether the connection is blocked.
* @return @p true if the connection is blocked.
*/
- bool blocked() const;
+ bool blocked() const noexcept;
/** Sets or unsets the blocking state of this connection.
* See slot_base::block() for details.
* @param should_block Indicates whether the blocking state should be set or unset.
* @return @p true if the connection has been in blocking state before.
*/
- bool block(bool should_block = true);
+ bool block(bool should_block = true) noexcept;
/** Unsets the blocking state of this connection.
* @return @p true if the connection has been in blocking state before.
*/
- bool unblock();
+ bool unblock() noexcept;
/// Disconnects the referred slot.
void disconnect();
+ //TODO: When we can break API and ABI, make operator bool() explicit and const
/** Returns whether the connection is still active.
* @return @p true if the connection is still active.
*/
- operator bool();
+ operator bool() noexcept;
/** Callback that is executed when the referred slot is destroyed.
* @param data The connection object notified (@p this).
diff --git a/sigc++/functors/slot_base.cc b/sigc++/functors/slot_base.cc
index 9340b02..1b8285a 100644
--- a/sigc++/functors/slot_base.cc
+++ b/sigc++/functors/slot_base.cc
@@ -25,9 +25,9 @@ namespace
// notified, if the slot_rep is deleted when they call disconnect().
struct destroy_notify_struct
{
- destroy_notify_struct() : deleted_(false) { }
+ destroy_notify_struct() noexcept : deleted_(false) { }
- static void* notify(void* data)
+ static void* notify(void* data) noexcept
{
auto self_ = reinterpret_cast<destroy_notify_struct*>(data);
self_->deleted_ = true;
@@ -96,12 +96,12 @@ void* slot_rep::notify(void* data)
} // namespace internal
-slot_base::slot_base()
+slot_base::slot_base() noexcept
: rep_(nullptr),
blocked_(false)
{}
-slot_base::slot_base(rep_type* rep)
+slot_base::slot_base(rep_type* rep) noexcept
: rep_(rep),
blocked_(false)
{}
@@ -162,7 +162,7 @@ slot_base::~slot_base()
delete rep_;
}
-slot_base::operator bool() const
+slot_base::operator bool() const noexcept
{
return rep_ != nullptr;
}
@@ -261,7 +261,7 @@ slot_base& slot_base::operator=(slot_base&& src)
return *this;
}
-void slot_base::set_parent(void* parent, void* (*cleanup)(void*)) const
+void slot_base::set_parent(void* parent, void* (*cleanup)(void*)) const noexcept
{
if (rep_)
rep_->set_parent(parent, cleanup);
@@ -279,14 +279,14 @@ void slot_base::remove_destroy_notify_callback(void* data) const
rep_->remove_destroy_notify_callback(data);
}
-bool slot_base::block(bool should_block)
+bool slot_base::block(bool should_block) noexcept
{
bool old = blocked_;
blocked_ = should_block;
return old;
}
-bool slot_base::unblock()
+bool slot_base::unblock() noexcept
{
return block(false);
}
diff --git a/sigc++/functors/slot_base.h b/sigc++/functors/slot_base.h
index 6577574..8ecd086 100644
--- a/sigc++/functors/slot_base.h
+++ b/sigc++/functors/slot_base.h
@@ -88,7 +88,7 @@ struct SIGC_API slot_rep : public trackable
/** Parent object whose callback cleanup_ is executed on notification. */
void* parent_;
- inline slot_rep(hook call__, hook destroy__, hook dup__)
+ inline slot_rep(hook call__, hook destroy__, hook dup__) noexcept
: call_(call__), destroy_(destroy__), dup_(dup__), cleanup_(nullptr), parent_(nullptr) {}
inline ~slot_rep()
@@ -116,7 +116,7 @@ struct SIGC_API slot_rep : public trackable
* @param parent The new parent.
* @param cleanup The callback to execute from notify().
*/
- inline void set_parent(void* parent, hook cleanup)
+ inline void set_parent(void* parent, hook cleanup) noexcept
{
parent_ = parent;
cleanup_ = cleanup;
@@ -147,7 +147,7 @@ struct SIGC_API slot_do_bind
/** Construct a slot_do_bind functor.
* @param rep The slot_rep object trackables should notify on destruction.
*/
- inline slot_do_bind(slot_rep* rep) : rep_(rep) {}
+ inline slot_do_bind(slot_rep* rep) noexcept : rep_(rep) {}
/** Adds a dependency to @p t.
* @param t The trackable object to add a callback to.
@@ -165,7 +165,7 @@ struct SIGC_API slot_do_unbind
/** Construct a slot_do_unbind functor.
* @param rep The slot_rep object trackables don't need to notify on destruction any more.
*/
- inline slot_do_unbind(slot_rep* rep) : rep_(rep) {}
+ inline slot_do_unbind(slot_rep* rep) noexcept : rep_(rep) {}
/** Removes a dependency from @p t.
* @param t The trackable object to remove the callback from.
@@ -250,12 +250,12 @@ class SIGC_API slot_base : public functor_base
// may throw an exception.
public:
/// Constructs an empty slot.
- slot_base();
+ slot_base() noexcept;
/** Constructs a slot from an existing slot_rep object.
* @param rep The slot_rep object this slot should contain.
*/
- explicit slot_base(rep_type* rep);
+ explicit slot_base(rep_type* rep) noexcept;
/** Constructs a slot, copying an existing one.
* @param src The existing slot to copy.
@@ -277,7 +277,7 @@ public:
* do_something()
* @endcode
*/
- operator bool() const;
+ operator bool() const noexcept;
/** Sets the parent of this slot.
* This function is used by signals to register a notification callback.
@@ -286,7 +286,7 @@ public:
* @param parent The new parent.
* @param cleanup The notification callback.
*/
- void set_parent(void* parent, void* (*cleanup)(void*)) const;
+ void set_parent(void* parent, void* (*cleanup)(void*)) const noexcept;
typedef trackable::func_destroy_notify func_destroy_notify;
/** Add a callback that is executed (notified) when the slot is detroyed.
@@ -305,13 +305,13 @@ public:
/** Returns whether the slot is invalid.
* @return @p true if the slot is invalid (empty).
*/
- inline bool empty() const
+ inline bool empty() const noexcept
{ return (!rep_ || !rep_->call_); }
/** Returns whether the slot is blocked.
* @return @p true if the slot is blocked.
*/
- inline bool blocked() const
+ inline bool blocked() const noexcept
{ return blocked_; }
/** Sets the blocking state.
@@ -322,12 +322,12 @@ public:
* @param should_block Indicates whether the blocking state should be set or unset.
* @return @p true if the slot was in blocking state before.
*/
- bool block(bool should_block = true);
+ bool block(bool should_block = true) noexcept;
/** Unsets the blocking state.
* @return @p true if the slot was in blocking state before.
*/
- bool unblock();
+ bool unblock() noexcept;
/** Disconnects the slot.
* Invalidates the slot and notifies the parent.
diff --git a/sigc++/signal_base.cc b/sigc++/signal_base.cc
index 7885a53..5ecadff 100644
--- a/sigc++/signal_base.cc
+++ b/sigc++/signal_base.cc
@@ -67,12 +67,12 @@ void signal_impl::clear()
slots_.clear();
}
-signal_impl::size_type signal_impl::size() const
+signal_impl::size_type signal_impl::size() const noexcept
{
return slots_.size();
}
-bool signal_impl::blocked() const
+bool signal_impl::blocked() const noexcept
{
for (const auto& slot : const_cast<const std::list<slot_base>&>(slots_))
{
@@ -82,7 +82,7 @@ bool signal_impl::blocked() const
return true;
}
-void signal_impl::block(bool should_block)
+void signal_impl::block(bool should_block) noexcept
{
for (auto& slot : slots_)
{
@@ -156,11 +156,11 @@ void* signal_impl::notify(void* d)
} /* namespace internal */
-signal_base::signal_base()
+signal_base::signal_base() noexcept
: impl_(nullptr)
{}
-signal_base::signal_base(const signal_base& src)
+signal_base::signal_base(const signal_base& src) noexcept
: trackable(),
impl_(src.impl())
{
@@ -193,23 +193,23 @@ void signal_base::clear()
impl_->clear();
}
-signal_base::size_type signal_base::size() const
+signal_base::size_type signal_base::size() const noexcept
{
return (impl_ ? impl_->size() : 0);
}
-bool signal_base::blocked() const
+bool signal_base::blocked() const noexcept
{
return (impl_ ? impl_->blocked() : true);
}
-void signal_base::block(bool should_block)
+void signal_base::block(bool should_block) noexcept
{
if (impl_)
impl_->block(should_block);
}
-void signal_base::unblock()
+void signal_base::unblock() noexcept
{
if (impl_)
impl_->block(false);
diff --git a/sigc++/signal_base.h b/sigc++/signal_base.h
index 03ae156..622135f 100644
--- a/sigc++/signal_base.h
+++ b/sigc++/signal_base.h
@@ -64,11 +64,11 @@ struct SIGC_API signal_impl
#endif
/// Increments the reference counter.
- inline void reference()
+ inline void reference() noexcept
{ ++ref_count_; }
/// Increments the reference and execution counter.
- inline void reference_exec()
+ inline void reference_exec() noexcept
{ ++ref_count_; ++exec_count_; }
/** Decrements the reference counter.
@@ -90,7 +90,7 @@ struct SIGC_API signal_impl
/** Returns whether the list of slots is empty.
* @return @p true if the list of slots is empty.
*/
- inline bool empty() const
+ inline bool empty() const noexcept
{ return slots_.empty(); }
/// Empties the list of slots.
@@ -99,14 +99,14 @@ struct SIGC_API signal_impl
/** Returns the number of slots in the list.
* @return The number of slots in the list.
*/
- size_type size() const;
+ size_type size() const noexcept;
/** Returns whether all slots in the list are blocked.
* @return @p true if all slots are blocked or the list is empty.
*
* @newin{2,4}
*/
- bool blocked() const;
+ bool blocked() const noexcept;
/** Sets the blocking state of all slots in the list.
* If @e should_block is @p true then the blocking state is set.
@@ -118,7 +118,7 @@ struct SIGC_API signal_impl
*
* @newin{2,4}
*/
- void block(bool should_block = true);
+ void block(bool should_block = true) noexcept;
/** Adds a slot at the bottom of the list of slots.
* @param slot_ The slot to add to the list of slots.
@@ -178,7 +178,7 @@ struct SIGC_API signal_exec
/** Increments the reference and execution counter of the parent sigc::signal_impl object.
* @param sig The parent sigc::signal_impl object.
*/
- inline signal_exec(const signal_impl* sig)
+ inline signal_exec(const signal_impl* sig) noexcept
: sig_(const_cast<signal_impl*>(sig) )
{ sig_->reference_exec(); }
@@ -286,9 +286,9 @@ struct SIGC_API signal_base : public trackable
{
typedef std::size_t size_type;
- signal_base();
+ signal_base() noexcept;
- signal_base(const signal_base& src);
+ signal_base(const signal_base& src) noexcept;
signal_base(signal_base&& src);
@@ -301,7 +301,7 @@ struct SIGC_API signal_base : public trackable
/** Returns whether the list of slots is empty.
* @return @p true if the list of slots is empty.
*/
- inline bool empty() const
+ inline bool empty() const noexcept
{ return (!impl_ || impl_->empty()); }
/// Empties the list of slots.
@@ -310,14 +310,14 @@ struct SIGC_API signal_base : public trackable
/** Returns the number of slots in the list.
* @return The number of slots in the list.
*/
- size_type size() const;
+ size_type size() const noexcept;
/** Returns whether all slots in the list are blocked.
* @return @p true if all slots are blocked or the list is empty.
*
* @newin{2,4}
*/
- bool blocked() const;
+ bool blocked() const noexcept;
/** Sets the blocking state of all slots in the list.
* If @e should_block is @p true then the blocking state is set.
@@ -330,13 +330,13 @@ struct SIGC_API signal_base : public trackable
*
* @newin{2,4}
*/
- void block(bool should_block = true);
+ void block(bool should_block = true) noexcept;
/** Unsets the blocking state of all slots in the list.
*
* @newin{2,4}
*/
- void unblock();
+ void unblock() noexcept;
protected:
typedef internal::signal_impl::iterator_type iterator_type;
diff --git a/sigc++/trackable.cc b/sigc++/trackable.cc
index 9faabc1..f7ac08d 100644
--- a/sigc++/trackable.cc
+++ b/sigc++/trackable.cc
@@ -27,13 +27,13 @@ using namespace std;
namespace sigc
{
-trackable::trackable()
+trackable::trackable() noexcept
: callback_list_(nullptr)
{}
/* Don't copy the notification list.
The objects watching src don't need to be notified when the new object dies. */
-trackable::trackable(const trackable& /*src*/)
+trackable::trackable(const trackable& /*src*/) noexcept
: callback_list_(nullptr)
{}
diff --git a/sigc++/trackable.h b/sigc++/trackable.h
index b82bbbb..6f9b017 100644
--- a/sigc++/trackable.h
+++ b/sigc++/trackable.h
@@ -37,7 +37,7 @@ struct SIGC_API trackable_callback
{
void* data_;
func_destroy_notify func_;
- trackable_callback(void* data, func_destroy_notify func)
+ trackable_callback(void* data, func_destroy_notify func) noexcept
: data_(data), func_(func) {}
};
@@ -113,9 +113,9 @@ struct SIGC_API trackable
// is called. It may throw an exception. A method that calls notify_callbacks()
// shall not be declared noexcept.
- trackable();
+ trackable() noexcept;
- trackable(const trackable& src);
+ trackable(const trackable& src) noexcept;
trackable(trackable&& src);