The following code
struct foo
{
foo ()
{ }
template <typename T0, typename ... Ts>
foo (const T0 & t0, const Ts & ... ts)
{ foo(ts...); }
};
int main()
{
foo f(1, 2);
return 0;
}
compile without problems with g++
(4.9.2) and give the following errors
tmp_002-11,14,gcc,clang.cpp:9:16: error: expected ')'
{ foo(ts...); }
^
tmp_002-11,14,gcc,clang.cpp:9:13: note: to match this '('
{ foo(ts...); }
^
tmp_002-11,14,gcc,clang.cpp:9:14: error: redefinition of 'ts'
{ foo(ts...); }
^
tmp_002-11,14,gcc,clang.cpp:8:42: note: previous definition is here
foo (const T0 & t0, const Ts & ... ts)
^
2 errors generated.
with clang++
(3.5).
As usual my question is: who's right?
--- EDIT ---
Clarification: I know that foo(ts...)
can't be a call to a delegate constructor but (I think that can be) the construction of a temporary foo
object (another foo
object).
But, as pointed by vsoftco, what's happening when sizeof...(ts) == 1U
?
In that case, foo(ts...);
is a (re)declaration of a single variable ts
(so, I suppose, should be right clang++
) or the variadic syntax avoid this problem (so, I suppose, should be right g++
)?
There are C++11 standard experts that can clarify this?
p.s.: sorry for my bad English.