lundi 4 juillet 2016

temporary objects with variadic template arguments; another g++/clang++ difference

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?

Aucun commentaire:

Enregistrer un commentaire