Deduction guides not working for gcc-10.1 and below but works for std::tuple

37 Views Asked by At

For the following code

template <typename... T>
struct Foo {
    template <typename... U>
    constexpr Foo(U&&... args)  {
        std::cout << "Foo arg size is " << sizeof...(args) << "\n";
        std::cout << "Foo template pack is " << sizeof...(T) << "\n";
    }
};
template<typename... _UTypes>
Foo(_UTypes...) -> Foo<_UTypes...>;

int main()
{
    Foo mp {1, 3, 5};
    return 0;
}

the deduction guide does not work for gcc-10.1 and below. "Foo template pack is" prints 0. As the code works with newer version of gcc, I assume it's a bug in the previous versions. But how come it works for std::tuple for the same gcc(10.1 and below) version?

If I create a tuple like this

std::tuple m{1 2, 4};

m's type is correctly deduced to be std::tuple<int, int, int>. How come the deduction guide works here but not with the Foo class.

Thanks,

0

There are 0 best solutions below