(I apologize for the title, but I couldn't come up with anything more descriptive)
This code fails to compile in g++ 8.x, but compiles in every other C++17-capable compiler (including g++ 7.x):
#include <variant>
#include <type_traits>
template<class... Ts> struct S
{
template<std::size_t idx> using vtype =
std::variant_alternative_t<idx, std::variant<Ts...>>;
template<bool B, class T = void> using enable_if = std::enable_if_t<B, T>;
template<class T, class U> static constexpr bool is_same = std::is_same<T, U>::value;
template<std::size_t idx, enable_if< is_same<vtype<idx>, int>>...>
static bool foo() { return true ; }
template<std::size_t idx, enable_if<!is_same<vtype<idx>, int>>...>
static bool foo() { return false; }
};
auto x = S<int, char, float>::foo<1>();
Why it fails to compile?
(I assume workaround would be to replace SFINAE+overloading with if constexpr
)