Is there a way to fix the following problem:
This code produces a C4702 warning 'unreachable code' (on VC++ 15.8 with /std:c++17
)
template <typename T, typename VariantType>
inline bool MatchMonostate( VariantType& variant )
{
SUPPRESS_C4100( variant );
if constexpr ( std::is_same_v<T, std::monostate> )
{
variant = std::monostate();
return true;
}
return false; // !!! unreachable if the above is true !!! => C4702
}
to suppress the C4100 'unreferenced formal parameter' warning, I'm already using the trick
#define SUPPRESS_C4100(x) ((void)x)
The simple idea of adding
else
{
return false;
}
results in warning C4715 'not all control paths return a value' instead.