Add `noexcept` to move constructors and move assignment operators
refs #2966
Change-Id: Ib87da2b8dc2d77fa9beb8bc6b5323498057b76a2
diff --git a/.waf-tools/type_traits.py b/.waf-tools/type_traits.py
index a895e07..efc4e3d 100644
--- a/.waf-tools/type_traits.py
+++ b/.waf-tools/type_traits.py
@@ -11,5 +11,5 @@
def configure(conf):
checkForTypeProperty(conf, 'is_default_constructible', 'int')
- checkForTypeProperty(conf, 'is_move_constructible', 'int')
- checkForTypeProperty(conf, 'is_move_assignable', 'int')
+ checkForTypeProperty(conf, 'is_nothrow_move_constructible', 'int')
+ checkForTypeProperty(conf, 'is_nothrow_move_assignable', 'int')
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 5e5f666..32016f8 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -33,15 +33,15 @@
namespace ndn {
-#if NDN_CXX_HAVE_IS_MOVE_CONSTRUCTIBLE
-static_assert(std::is_move_constructible<Buffer>::value,
- "Buffer must be MoveConstructible");
-#endif // NDN_CXX_HAVE_IS_MOVE_CONSTRUCTIBLE
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+static_assert(std::is_nothrow_move_constructible<Block>::value,
+ "Block must be MoveConstructible with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
-#if NDN_CXX_HAVE_IS_MOVE_ASSIGNABLE
-static_assert(std::is_move_assignable<Buffer>::value,
- "Buffer must be MoveAssignable");
-#endif // NDN_CXX_HAVE_IS_MOVE_ASSIGNABLE
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
+static_assert(std::is_nothrow_move_assignable<Block>::value,
+ "Block must be MoveAssignable with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
const size_t MAX_SIZE_OF_BLOCK_FROM_STREAM = 8800;
diff --git a/src/encoding/buffer.cpp b/src/encoding/buffer.cpp
index 0402d7d..940ed88 100644
--- a/src/encoding/buffer.cpp
+++ b/src/encoding/buffer.cpp
@@ -25,15 +25,15 @@
namespace ndn {
-#if NDN_CXX_HAVE_IS_MOVE_CONSTRUCTIBLE
-static_assert(std::is_move_constructible<Buffer>::value,
- "Buffer must be MoveConstructible");
-#endif // NDN_CXX_HAVE_IS_MOVE_CONSTRUCTIBLE
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+static_assert(std::is_nothrow_move_constructible<Buffer>::value,
+ "Buffer must be MoveConstructible with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
-#if NDN_CXX_HAVE_IS_MOVE_ASSIGNABLE
-static_assert(std::is_move_assignable<Buffer>::value,
- "Buffer must be MoveAssignable");
-#endif // NDN_CXX_HAVE_IS_MOVE_ASSIGNABLE
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
+static_assert(std::is_nothrow_move_assignable<Buffer>::value,
+ "Buffer must be MoveAssignable with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_ASSIGNABLE
Buffer::Buffer()
{
diff --git a/src/util/scheduler-scoped-event-id.cpp b/src/util/scheduler-scoped-event-id.cpp
index c69af3b..2858749 100644
--- a/src/util/scheduler-scoped-event-id.cpp
+++ b/src/util/scheduler-scoped-event-id.cpp
@@ -25,12 +25,17 @@
namespace util {
namespace scheduler {
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+static_assert(std::is_nothrow_move_constructible<ScopedEventId>::value,
+ "ScopedEventId must be MoveConstructible with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+
ScopedEventId::ScopedEventId(Scheduler& scheduler)
: m_scheduler(&scheduler)
{
}
-ScopedEventId::ScopedEventId(ScopedEventId&& other)
+ScopedEventId::ScopedEventId(ScopedEventId&& other) noexcept
: m_scheduler(other.m_scheduler)
, m_event(other.m_event)
{
diff --git a/src/util/scheduler-scoped-event-id.hpp b/src/util/scheduler-scoped-event-id.hpp
index 89cab89..1391d5d 100644
--- a/src/util/scheduler-scoped-event-id.hpp
+++ b/src/util/scheduler-scoped-event-id.hpp
@@ -42,7 +42,7 @@
/** \brief move constructor
*/
- ScopedEventId(ScopedEventId&& other);
+ ScopedEventId(ScopedEventId&& other) noexcept;
/** \brief assigns an event
*
diff --git a/src/util/signal-scoped-connection.cpp b/src/util/signal-scoped-connection.cpp
index a0f2d1c..1b1fb95 100644
--- a/src/util/signal-scoped-connection.cpp
+++ b/src/util/signal-scoped-connection.cpp
@@ -25,6 +25,11 @@
namespace util {
namespace signal {
+#if NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+static_assert(std::is_nothrow_move_constructible<ScopedConnection>::value,
+ "ScopedConnection must be MoveConstructible with noexcept");
+#endif // NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE
+
ScopedConnection::ScopedConnection()
{
}
@@ -34,7 +39,7 @@
{
}
-ScopedConnection::ScopedConnection(ScopedConnection&& other)
+ScopedConnection::ScopedConnection(ScopedConnection&& other) noexcept
: m_connection(other.m_connection)
{
other.release();
diff --git a/src/util/signal-scoped-connection.hpp b/src/util/signal-scoped-connection.hpp
index 80717e5..04a4bb3 100644
--- a/src/util/signal-scoped-connection.hpp
+++ b/src/util/signal-scoped-connection.hpp
@@ -42,7 +42,7 @@
/** \brief move constructor
*/
- ScopedConnection(ScopedConnection&& other);
+ ScopedConnection(ScopedConnection&& other) noexcept;
/** \brief assigns a connection
*