From 4afdf8745a873a813cc8c7cee412a68666a03c9b Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Tue, 31 Oct 2023 16:57:14 -0700 Subject: [PATCH] Apply conditional noexcept to Expected's constructors. (#1251) --- include/vcpkg/base/expected.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/vcpkg/base/expected.h b/include/vcpkg/base/expected.h index 9ead2d49ed..49ced29d1c 100644 --- a/include/vcpkg/base/expected.h +++ b/include/vcpkg/base/expected.h @@ -74,7 +74,8 @@ namespace vcpkg std::enable_if_t && !std::is_same_v, Error>, int> = 0> - ExpectedT(ConvToT&& t) : m_t(std::forward(t)), value_is_error(false) + ExpectedT(ConvToT&& t) noexcept(std::is_nothrow_constructible_v) + : m_t(std::forward(t)), value_is_error(false) { } @@ -83,18 +84,21 @@ namespace vcpkg !std::is_same_v, T>, int> = 0, int = 1> - ExpectedT(ConvToError&& e) : m_error(std::forward(e)), value_is_error(true) + ExpectedT(ConvToError&& e) noexcept(std::is_nothrow_constructible_v) + : m_error(std::forward(e)), value_is_error(true) { } // Constructors that explicitly specify left or right exist if the parameter is convertible to T or Error template, int> = 0> - ExpectedT(ConvToT&& t, ExpectedLeftTag) : m_t(std::forward(t)), value_is_error(false) + ExpectedT(ConvToT&& t, ExpectedLeftTag) noexcept(std::is_nothrow_constructible_v) + : m_t(std::forward(t)), value_is_error(false) { } template, int> = 0> - ExpectedT(ConvToError&& e, ExpectedRightTag) : m_error(std::forward(e)), value_is_error(true) + ExpectedT(ConvToError&& e, ExpectedRightTag) noexcept(std::is_nothrow_constructible_v) + : m_error(std::forward(e)), value_is_error(true) { }