diff options
| -rw-r--r-- | src/stdplus/handle/copyable.hpp | 12 | ||||
| -rw-r--r-- | src/stdplus/handle/managed.hpp | 16 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/stdplus/handle/copyable.hpp b/src/stdplus/handle/copyable.hpp index df383db..ef93263 100644 --- a/src/stdplus/handle/copyable.hpp +++ b/src/stdplus/handle/copyable.hpp @@ -1,6 +1,7 @@ #pragma once #include <optional> #include <stdplus/handle/managed.hpp> +#include <type_traits> #include <utility> namespace stdplus @@ -40,13 +41,12 @@ struct Copyable * @param[in] maybeV - Maybe the object being managed */ template <typename... Vs> - constexpr explicit Handle(std::optional<T>&& maybeV, - Vs&&... vs) noexcept : + constexpr explicit Handle(std::optional<T>&& maybeV, Vs&&... vs) : MHandle(std::move(maybeV), std::forward<Vs>(vs)...) { } template <typename... Vs> - constexpr explicit Handle(T&& maybeV, Vs&&... vs) noexcept : + constexpr explicit Handle(T&& maybeV, Vs&&... vs) : MHandle(std::move(maybeV), std::forward<Vs>(vs)...) { } @@ -56,7 +56,9 @@ struct Copyable reset(other.maybe_value()); } - constexpr Handle(Handle&& other) noexcept : MHandle(std::move(other)) + constexpr Handle(Handle&& other) noexcept( + std::is_nothrow_move_constructible_v<MHandle>) : + MHandle(std::move(other)) { } @@ -71,7 +73,7 @@ struct Copyable return *this; } - constexpr Handle& operator=(Handle&& other) noexcept + constexpr Handle& operator=(Handle&& other) { MHandle::operator=(std::move(other)); return *this; diff --git a/src/stdplus/handle/managed.hpp b/src/stdplus/handle/managed.hpp index de6a9f1..94c0bfa 100644 --- a/src/stdplus/handle/managed.hpp +++ b/src/stdplus/handle/managed.hpp @@ -2,6 +2,7 @@ #include <cstdlib> #include <optional> #include <tuple> +#include <type_traits> #include <utility> namespace stdplus @@ -37,14 +38,12 @@ struct Managed * @param[in] maybeV - Maybe the object being managed */ template <typename... Vs> - constexpr explicit Handle(std::optional<T>&& maybeV, - Vs&&... vs) noexcept : - as(std::forward<Vs>(vs)...), - maybeT(std::move(maybeV)) + constexpr explicit Handle(std::optional<T>&& maybeV, Vs&&... vs) : + as(std::forward<Vs>(vs)...), maybeT(std::move(maybeV)) { } template <typename... Vs> - constexpr explicit Handle(T&& maybeV, Vs&&... vs) noexcept : + constexpr explicit Handle(T&& maybeV, Vs&&... vs) : as(std::forward<Vs>(vs)...), maybeT(std::move(maybeV)) { } @@ -52,8 +51,11 @@ struct Managed Handle(const Handle& other) = delete; Handle& operator=(const Handle& other) = delete; - constexpr Handle(Handle&& other) : - as(std::move(other.as)), maybeT(std::move(other.maybeT)) + constexpr Handle(Handle&& other) noexcept( + std::is_nothrow_move_constructible_v<std::tuple<As...>>&& + std::is_nothrow_move_constructible_v<std::optional<T>>) : + as(std::move(other.as)), + maybeT(std::move(other.maybeT)) { other.maybeT = std::nullopt; } |

