mardi 3 novembre 2015

How can I generate a tuple of N type T's?

I want to be able to write generate_tuple_type<int, 3> which would internally have a type alias type which would be std::tuple<int, int, int> in this case.

Some sample usage:

int main()
{
    using gen_tuple_t = generate_tuple_type<int, 3>::type;
    using hand_tuple_t = std::tuple<int, int, int>;
    static_assert( std::is_same<gen_tuple_t, hand_tuple_t>::value, "different types" );
}

How can I accomplish this?

Aucun commentaire:

Enregistrer un commentaire