template<typename ... Types1, typename ... Types2>
class Foo;
gcc 4.4.1 both says no and says why:
vartemp.cpp:33: error: parameter pack 'Types1' must be at the end of the
template parameter list
I can't find wording to back up this restriction, and in fact I find the
following in 20.5.2.7 of N3000:
template<class... TTypes, class... UTypes>
bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
Is this a bug in gcc or a part of the draft standard that requires
amendment? If it's a gcc bug, am I correct in assuming that a
straightforward way to process variadic template parameters back-to-front
is:
template<typename ... Ts> struct Foo;
template<typename ... FirstTypes, typename LastType>
struct Foo<FirstTypes..., LastType> {
// do something with LastType, then recur to handle
// the types in FirstTypes
};
Thanks,
Scott
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use
mailto:std...@netlab.cs.rpi.edu<std-c%2B%2...@netlab.cs.rpi.edu>
]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
See N3000 - 14.2/11: "If a template-parameter of a class template is a
template parameter pack, it shall be the last template-parameter.
[ Note: These are not requirements for function templates because
template arguments might be deduced (14.9.2)."
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@netlab.cs.rpi.edu]
Hi Scott.
One explanation for why packs are restricted to the end
is found here:
http://groups.google.com/group/comp.lang.c++.moderated/msg/e3c48abcdda846f0?hl=en
That's unfortunate because I would find them useful :(
HTH.
-Larry
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@netlab.cs.rpi.edu]
I think Scott brings up a valid point. I understand that multiple
parameter packs are not allowed for declaring a class template because
the user *has* to specify the arguments. The draft clearly allows
multiple parameter packs for function templates because template
parameters can be deduced. But the same is true for specializations.
The template parameters for a specialization are also deduced and
*never* supplied explicitly by the user.
So, I agree with Scott. I don't see a single reason why this
restriction should apply to class template *specializations* as well.
Either this is a serious and unfounded limitation of the draft or
GCC's implementation is just buggy. I think it's the latter because it
doesn't look like the section of the draft you quoted applies to class
template specializations.
Cheers,
SG
i actually brought up this point a few months ago argumenting the same
point as Scott:
this would be a great feature added to variadic templates and Douglas
Gregor, at the time, seem to be saying that it could be introduced as
a defect fix.
I really hope it makes it in C++0x
Olivier Grant
> Either this is a serious and unfounded limitation of the draft or
> GCC's implementation is just buggy. I think it's the latter because it
> doesn't look like the section of the draft you quoted applies to class
> template specializations.
>
> Cheers,
> SG
>
> --
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-...@netlab.cs.rpi.edu]