In the following line:return maxvalue(I, ...);
You're not indicating what you want to do with it. ..., must always be preceded by an operator that applies to an identifier (which should be I) so if you just want to pass the same parameters then just leave a blank space between I and ... to expand properly as in this example:#include <iostream>
#include <utility>
template <typename T, typename ... V>
constexpr T maxvalue(T A, T B, V ... v)
{
if constexpr (sizeof...(v) == 0)
return A > B ? A : B;
else
return maxvalue(A, maxvalue(B, v ...));
}
template <typename T, typename ... V>
constexpr T maxvalue(T A, T B, T C, V ... v)
{
if constexpr (sizeof...(v) == 0)
return maxvalue(A, maxvalue(B, C));
else
return maxvalue(A, maxvalue(B, maxvalue(C, v ...)));
}
template <typename R, auto ... I>
R f(std::integer_sequence<R, I ...>)
{
return maxvalue(I ...);
}
int main() {
std::cout << maxvalue(1, 2, 3, 5, 8, 13, 42, 15, 9, 4) << std::endl;
std::cout << f(std::integer_sequence<int, 1, 2, 3, 5, 8, 13, 42, 15, 9, 4>{}) << std::endl;
}
I write it:$ g++ -o poc -std=c++1z poc.cpp
And when I execute it:$ ./poc
42
42