CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2018-12-15
by Nelfeal

Original Post

Original - Posted on 2015-07-29
by Barry



            
Present in both answers; Present only in the new answer; Present only in the old answer;

The fact that N cannot be deduced has nothing to do with the parameter pack. This doesn't compile either because N cannot be deduced.
template<int N> void f(double (&)[N+1]) {} int main() { double arr[2]; f(arr); }
The fact that N cannot be specified has a different cause: the standard says that you simply cannot specify a parameter placed after a parameter pack.
From [temp.param]: > A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced from the *parameter-type-list* of the function template or has a default argument (14.8.2). *[Example:* > template<class T1 = int, class T2> class B; // error > // U can be neither deduced from the parameter-type-list nor specified template<class... T, class... U> void f() { } // error template<class... T, class U> void g() { } // error > *—end example ]*
(see [this question](https://stackoverflow.com/questions/31697055/are-multiple-non-type-template-parameter-packs-allowed) from which I got the quote)
No, it not allowed by the standard. From [temp.param]:
> A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced from the *parameter-type-list* of the function template or has a default argument (14.8.2). *[Example:* > template<class T1 = int, class T2> class B; // error > // U can be neither deduced from the parameter-type-list nor specified template<class... T, class... U> void f() { } // error template<class... T, class U> void g() { } // error > *—end example ]*
In your case, `...B` cannot be deduced (as there's nothing to deduce it from) and it has no default argument.
> so what exactly needs to be deduced for the packs (just the type, or the values, too)?
For example, if your `foo` was:
template <size_t... A, size_t... B> void foo(std::index_sequence<B...> );
`...A` is followed by `...B`, but `...B` can be deduced, so that's allowed. Similarly:
template <typename T, T... A, T B = 0> void foo();
is fine, as `B` has a default argument.

        
Present in both answers; Present only in the new answer; Present only in the old answer;