I have the following code, where I am using a fold expression to evaluate whether all pack parameters are convertible to the first function argument. For some reason it fails to compile on msvc when I make what seems like a very trivial change:
#include <type_traits>
#define TRY 1
#if TRY == 1
template<typename B, typename... Args,
std::enable_if_t<((std::is_convertible_v<Args&, B&> && ...)), bool> = true>
void fn(B b, Args...args) {}
#else
template<typename B, typename... Args,
typename = std::enable_if_t<(std::is_convertible_v<Args&, B&> && ...)>>
void fn(B b, Args...args) {}
#endif
int main()
{
fn(5, 4, 2);
return 0;
}
Change TRY
to 0
to have it compile, demo at: https://godbolt.org/z/EGvQ-N
Is there an important difference between the two variants that I am missing, or is this a compiler bug?