iFreilicht
iFreilicht

Reputation: 14464

Is it possible to use typenames after an unpacked list as templates arguments?

In the most basic sense, I want to do this:

template<typename ... Args>
struct{
    typedef std::tuple<Args ..., int> myTuple;
}

But MSVC (in VisualStudio 2013) gives me quite a strange syntax error:

error C2143: syntax error : missing ';' before 'int'

Is it possible to use a regular typename after an unpacked list as template arguments? If yes, how? If no, why not?

Upvotes: 0

Views: 70

Answers (1)

Columbo
Columbo

Reputation: 60979

Is it possible to use a regular typename after an unpacked list as template arguments?

Yes, absolutely. You can insert arguments before and after a pack expansion in an argument list, and it is done exactly how you showed it. This is merely another example of how useless VC++ (or in this case, it's error messages) is when it comes to templates and recently introduces features.

By experimenting with an online compiler I found the problem to be the missing semicolon after the struct definition. For some reason the compiler error thus produced by VC++ refers to the tuple instead of the end of the struct. So, check for missing semicolons.

Upvotes: 3

Related Questions