make_unexpected in a function marked noexcept
zomgrolf opened this issue · 0 comments
Hi,
I have a function that returns tl::expected<int, std::exception_ptr>
and is marked as noexcept
. Inside that function I try to catch any exception that might be in flight and wrap it in tl::expected
by calling tl::make_unexpected(std::current_exception())
. That, unsurprisingly, compiles just fine. If I then attempt to run the code analysis (VS 2019 16.3) on said function, I get the following warning: C26447: The function is declared 'noexcept' but calls function 'make_unexpected<std::exception_ptr>()' which may throw exceptions (f.6).
Obviously, I can suppress this warning, but I'd like to know, if there's a way to call make_unexpected
inside a noexcept function, that avoids triggering this particular warning? Other than modifying expected.hpp
and making th make_unexpected
fn and unexpected
ctors conditionally noexcept (if the error type is noexcept copy-constructible or noexcept move-constructible)?