wrong type-traits gets called c++ [closed]

  ambiguous, c++, struct, typetraits
template <typename, typename>
struct my_struct;

template <typename T>
struct my_struct<T, tuple<>>
{
    using type = int;
};

template <typename T, typename Head, typename ...Tail>
struct my_struct<T, tuple<Head, Tail...>>
{
    using type = bool;
};

template <typename T, typename Head, typename ... Tail>
using my_struct_t = typename my_struct<T, tuple<Head, Tail...>>::type;

Above is the type trait I wrote. In the main function there is this line using my_type = my_struct_t< string, tuple<char, string, bool> >; and it is supposed to call struct my_struct<T, tuple<Head, Tail...>> but instead it calls struct my_struct<T, tuple<>>

Why is this happening and how can I fix this issue?

(In order to see which specialization is getting called you can do the following: template<typename ...> struct my_diplayer;. Then in the main function you can write my_displayer< my_type > a; to see through a compiler error that the type is int and not bool as I expect it to be because of my_struct_t)

Source: Windows Questions C++

LEAVE A COMMENT