How to understand variadic templates in c++11 -


sometimes use(. . .)to indicate template or function parameter represents pack. pack expansion putting (. . . ) right of pattern.

i little confused 2 occasions above.

in c++ standard document(14.5.3 item 4):

"in function parameter pack (8.3.5); pattern parameter-declaration without ellipsis."

there’s 1 example quote:

template<typename ...t1> void  f1(t1 ...t1) { } 

according above description,for function parameter pack,the pattern (t1 t1). why can't somethig that, put (...) right of pattern,then can code below:

template<typename ...t2> void  f2(t2 ...t2...) // f2(t2 ...t2...) -> f2((t2 ...t2)...)->f2((t2 t2)...) { } 

i confusedly think (...) after t2 mean pack expansion the pattern (t2 t2).then found code compiled success in vs2013.wow, find inspiration yet?

i brazenly began new attempt.

there’s quote in c++ standard(14.5.3 item 4):

"in template parameter pack pack expansion (14.1): — if template parameter pack parameter-declaration; pattern parameter-declaration without ellipsis;"

template<typename ...t3> void  f1(t3 ...t3) { } 

according description, template parameter t3, pattern (typename t3), so:

template<typename ...t4...>  class get_a_error; // template<(typename ...t4)...> -> template<(typename t4)...> 

without (...) pattern (typename t4),so put (...) right of pattern,then got error.

finally,i fell confusion.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -