It might be not very efficient to talk about the language syntax that has already been set in stone.
I would, however, like to see why the C++11 variadic template's argument expansion
couldn't be more explicit to read when it comes to some nested usage.
For example, I think C++ developers could've generally written code more clearly as follows. (If that's allowed)
template<typename ...> struct Tuple
{
};
template<typename T1, typename T2> struct Pair
{
};
template<class ...Args1> struct zip
{
template<class ...Args2> struct with
{
typedef Tuple<Pair<Args1, Args2>...> type;
// More code but but maybe better readability?
// because Args1, and Args2 are the ones that get
// actually expanded, not Pair<T, T>.
// typedef Tuple<Pair<Args1..., Args2...>> type; // ## Invalid! ##
};
};
typedef zip<short, int>::with<unsigned short, unsigned>::type T1;
By doing so we don't really have to get confused which template types are exactly being expanded or should be the ones that will have to be expanded when making multiple-nested variadic template
, because then it becomes more important for your code to look clearer than being shortened.
Plus I'd love to see the code in the same manner where I call a function as follows:
Foo(args...);
We don't do like this:
Foo(args)...;
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire