From 61ccdb0c7be7043f55c70ff6bc98612e690c6f48 Mon Sep 17 00:00:00 2001 From: Andreas Reischuk Date: Wed, 3 Jul 2024 14:54:32 +0200 Subject: [PATCH] Avoid ureachable code waring in latest MSVC 17.10.3 --- src/variant19.lib/variant19/Variant.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/variant19.lib/variant19/Variant.h b/src/variant19.lib/variant19/Variant.h index 53b9522..0cdec9f 100644 --- a/src/variant19.lib/variant19/Variant.h +++ b/src/variant19.lib/variant19/Variant.h @@ -54,6 +54,10 @@ template constexpr auto selectVariantWhichValue() { // fail … } +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4702) // we expect unreachable return code +#endif template constexpr auto visitRecursive(V&& v, F&& f, IndexPack*) -> decltype(auto) { if (I == v.which) { @@ -79,6 +83,9 @@ constexpr auto amendVisitRecursive(V&& v, F&& f, IndexPack*) -> declty META19_UNREACHABLE(); } } +#if defined(_MSC_VER) +# pragma warning(pop) +#endif } // namespace details @@ -254,11 +261,11 @@ template struct Variant { /// Convinience function to overload all given lambdas template requires(sizeof...(Fs) > 0) constexpr auto visitOverloaded(Fs&&... fs) const -> decltype(auto) { - return indexed.visitImpl(Overloaded{(Fs &&) fs...}); + return indexed.visitImpl(Overloaded{(Fs&&)fs...}); } template requires(sizeof...(Fs) > 0) constexpr auto amendOverloaded(Fs&&... fs) -> decltype(auto) { - return indexed.amendVisitImpl(Overloaded{(Fs &&) fs...}); + return indexed.amendVisitImpl(Overloaded{(Fs&&)fs...}); } /// inplace change of indexed type inside variant