https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71267

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-05-25
            Summary|recursive metafunction      |[C++14] recursive
                   |won't compile: no type      |metafunction won't compile:
                   |named 'type'                |no type named 'type'
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a reduced such that we don't depend on any headers:
template <typename Ts, Ts... a>
struct tt{};

template <typename... Ts>
struct typelist {};

// specialization of typelist for std::integral_constant<>s
#ifdef WORKS
template <typename T, T... Ints>
struct integer_typelist {};
#else
template <typename T, T... Ints>
using integer_typelist = typelist<tt<T, Ints>...>;
#endif

// helper metafunction to generate typelist<> of integral_constant<>s by
// specifying a Start, End, and Step value
template <int Start, int End, int Step, typename Seq, bool B = (Start < End)>
struct make_integer_list_impl;

// specialization for: Start < End
template <int Start, int End, int Step, int... Indexes>
struct make_integer_list_impl<Start, End, Step, integer_typelist<int,
Indexes...>, true>
{
    typedef typename make_integer_list_impl<
                              Start+Step, End, Step,
                              integer_typelist<int, Indexes..., Start>
                          >::type type;
};

// specialization for: Start >= End (terminate the recursion)
template <int Start, int End, int Step, int... Indexes>
struct make_integer_list_impl<Start, End, Step, integer_typelist<int,
Indexes...>, false>
{
    using type = integer_typelist<int, Indexes...>;
};

// helper alias template
template <int Start, int End, int Step>
using make_integer_typelist = typename
          make_integer_list_impl<Start, End, Step,
integer_typelist<int>>::type;

int main()
{
    // typelist<
    //     std::integral_constant<int,  0>,
    //     std::integral_constant<int,  3>,
    //     std::integral_constant<int,  6>,
    //     std::integral_constant<int,  9>,
    //     std::integral_constant<int, 12>
    // >
    using t2 = make_integer_typelist<0, 13, 3>;
}


----- CUT ----
If we change integer_typelist to a template struct instead of an using alias,
it works.

Reply via email to