handle: Improve noexcept qualification
Now that we are using functors, it should be possible to detect noexcept
state from the Drop / Ref functors and decide the proper noexcept values
for our functions based on that.
Change-Id: I30e7d71bab69a103ee9f713f4f029f4fab0b2dc8
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/handle/copyable.cpp b/test/handle/copyable.cpp
index b55b216..cd17c54 100644
--- a/test/handle/copyable.cpp
+++ b/test/handle/copyable.cpp
@@ -68,6 +68,18 @@
using StoreHandle =
Copyable<int, std::string, int>::HandleF<StoreDrop, StoreRef>;
+static_assert(std::is_nothrow_copy_constructible_v<SimpleHandle>);
+static_assert(std::is_nothrow_move_constructible_v<SimpleHandle>);
+static_assert(std::is_nothrow_move_assignable_v<SimpleHandle>);
+static_assert(std::is_nothrow_destructible_v<SimpleHandle>);
+static_assert(noexcept(std::declval<SimpleHandle>().reset()));
+static_assert(!std::is_nothrow_copy_constructible_v<StoreHandle>);
+// http://cplusplus.github.io/LWG/lwg-active.html#2116
+// static_assert(std::is_nothrow_move_constructible_v<StoreHandle>);
+static_assert(!std::is_nothrow_move_assignable_v<StoreHandle>);
+static_assert(!std::is_nothrow_destructible_v<StoreHandle>);
+static_assert(!noexcept(std::declval<StoreHandle>().reset()));
+
class CopyableHandleTest : public ::testing::Test
{
protected:
diff --git a/test/handle/managed.cpp b/test/handle/managed.cpp
index fffffde..fb89195 100644
--- a/test/handle/managed.cpp
+++ b/test/handle/managed.cpp
@@ -41,6 +41,16 @@
using SimpleHandle = Managed<int>::HandleF<SimpleDrop>;
using StoreHandle = Managed<int, std::string, int>::HandleF<StoreDrop>;
+static_assert(std::is_nothrow_move_constructible_v<SimpleHandle>);
+static_assert(std::is_nothrow_move_assignable_v<SimpleHandle>);
+static_assert(std::is_nothrow_destructible_v<SimpleHandle>);
+static_assert(noexcept(std::declval<SimpleHandle>().reset()));
+// http://cplusplus.github.io/LWG/lwg-active.html#2116
+// static_assert(std::is_nothrow_move_constructible_v<StoreHandle>);
+static_assert(!std::is_nothrow_move_assignable_v<StoreHandle>);
+static_assert(!std::is_nothrow_destructible_v<StoreHandle>);
+static_assert(!noexcept(std::declval<StoreHandle>().reset()));
+
class ManagedHandleTest : public ::testing::Test
{
protected: