Skip to content

Commit

Permalink
Avoid ureachable code waring in latest MSVC 17.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
arBmind committed Jul 3, 2024
1 parent a0bc396 commit 61ccdb0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/variant19.lib/variant19/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ template<size_t N> constexpr auto selectVariantWhichValue() {
// fail …
}

#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4702) // we expect unreachable return code
#endif
template<class T, class... Ts, class V, class F, size_t I, size_t... Is>
constexpr auto visitRecursive(V&& v, F&& f, IndexPack<I, Is...>*) -> decltype(auto) {
if (I == v.which) {
Expand All @@ -79,6 +83,9 @@ constexpr auto amendVisitRecursive(V&& v, F&& f, IndexPack<I, Is...>*) -> declty
META19_UNREACHABLE();
}
}
#if defined(_MSC_VER)
# pragma warning(pop)
#endif

} // namespace details

Expand Down Expand Up @@ -254,11 +261,11 @@ template<class... Ts> struct Variant {
/// Convinience function to overload all given lambdas
template<class... Fs> 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<class... Fs> 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
Expand Down

0 comments on commit 61ccdb0

Please sign in to comment.