diff --git a/include/common/result.hpp b/include/common/result.hpp index 5706bcb0..b4054fe6 100644 --- a/include/common/result.hpp +++ b/include/common/result.hpp @@ -33,6 +33,7 @@ class Result { * - T must have a default constructor */ constexpr Result() + noexcept(std::is_nothrow_default_constructible_v) requires std::default_initializable = default; @@ -47,6 +48,7 @@ class Result { * - T must be constructible with perfectly forwarded value argument */ template + noexcept(std::nothrow_constructible_from_v) requires std::constructible_from constexpr Result(U&& value) : value(std::forward(value)) {} @@ -60,6 +62,7 @@ class Result { * - T must be default initializable */ constexpr Result(E error) + noexcept(std::is_nothrow_default_constructible_v) requires std::default_initializable : error(error) {} @@ -75,6 +78,7 @@ class Result { * - T must be constructible with perfectly forwarded value argument */ template + noexcept(std::nothrow_constructible_from_v) requires std::constructible_from constexpr Result(E error, U&& value) : error(error), @@ -85,7 +89,7 @@ class Result { * * @return T& */ - constexpr operator T&() & { + constexpr operator T&() & noexcept { return value; } @@ -94,7 +98,7 @@ class Result { * * @return const T& */ - constexpr operator const T&() const& { + constexpr operator const T&() const& noexcept { return value; } @@ -103,7 +107,7 @@ class Result { * * @return T&& */ - constexpr operator T&&() && { + constexpr operator T&&() && noexcept { return std::move(value); } @@ -117,7 +121,7 @@ class Result { * @return "normal" value */ template - constexpr auto get_value(this Self&& self) { + constexpr auto get_value(this Self&& self) noexcept(noexcept(std::forward(self).value)) { return std::forward(self).value; } @@ -127,7 +131,7 @@ class Result { * @return true an error is contained * @return false an error is not contained */ - constexpr bool has_error() { + constexpr bool has_error() const noexcept { return error.has_value(); } @@ -139,7 +143,7 @@ class Result { * @return true error is contained * @return false error is not contained */ - constexpr bool contains(E error) { + constexpr bool contains(E error) const noexcept(noexcept(std::declval() == std::declval())) { return this->error == error; } @@ -147,4 +151,4 @@ class Result { bool operator==(const Result& other) = delete; }; -} // namespace zest \ No newline at end of file +} // namespace zest