I get a error for an unexpanded parameter pack while expanding it.
This code is for testing purposes.
Later i want to call a differrent function with the head, tail and element. I need the element to call another template function and want to maintain the other argument to later call a different template function.
Current output of clang (version: 8.0.0)
test.cpp
#include <iostream>
template <int... Tail>
class for_each_type {
public:
template <int element, int... Head>
int each() {
for_each_type<Tail..., element> _for;
_for.each<Head...>();
return element;
}
template <int element>
int each() {
return element;
}
};
int main() {
for_each_type<> _for;
std::cout << _for.each<1, 1, 2, 2>() << std::endl;
}
I expect the code to output 6
, but the actual output is a error message.
To run start the compiler i just run clang++ test.cpp
The current error message is:
C:\Users\HP\Documents\GitHub\CPP-Game-Engine\src>clang++ test.cpp
test.cpp:10:23: error: expected ';' after expression
_for.each<Head...>();
^
;
test.cpp:10:9: error: expression contains unexpanded parameter pack 'Head'
_for.each<Head...>();
^ ~~~~
test.cpp:10:23: error: expected expression
_for.each<Head...>();
^
3 errors generated.