Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are typelists completely replaced by variadic templates?

I'm reading through Modern C++ Design and the thought occurred to me that the typelist construct may be replacable by variadic templates. Both seem to rely on recursion to process the first type in the list and the remainder of the list separately. Is there anything typelists allow you to do that a variadic template wouldn't?

like image 917
masrtis Avatar asked Jun 13 '13 16:06

masrtis


1 Answers

Typelists allow you a few things. For example, you cannot have a variadic argument pack as the result of a metafunction - there's just no way to express something like this:

template <typename... Args>
struct argpack_id {
    typedef Args result;
};

You can do this with typelists.

On the other hand, you should probably implement the typelist itself as

template <typename... Args>
struct TypeList {};
like image 180
Sebastian Redl Avatar answered Nov 25 '22 06:11

Sebastian Redl