what does this ... (three dots) means in c++
It may seems a silly question, but when I try to look at this answer in SOF,
Compile time generated tables
I noted statements such as this:
template<
typename IntType, std::size_t Cols,
IntType(*Step)(IntType),IntType Start, std::size_t ...Rs
>
constexpr auto make_integer_matrix(std::index_sequence<Rs...>)
{
return std::array<std::array<IntType,Cols>,sizeof...(Rs)>
{{make_integer_array<IntType,Step,Start + (Rs * Cols),Cols>()...}};
}
more specifically :
std::size_t ...Rs
or
std::index_sequence<Rs...>
what does ... means here?
Edit 1
The question that reported as the original question related to this question is not correct:
That question can not answer these two cases (as they are not functions with variable number of arguments)
std::size_t ...Rs
std::index_sequence<Rs...>
But this is a good explanation:
https://xenakios.wordpress.com/2014/01/16/c11-the-three-dots-that-is-variadic-templates-part/
Solution 1:
Its called a parameter pack and refers to zero or more template parameters:
http://en.cppreference.com/w/cpp/language/parameter_pack
std::size_t ...Rs
is the parameter pack of type std::size_t
.
A variable of that type (e.g. Rs... my_var
) can be unpacked with:
my_var...
This pattern is heavily used in forwarding an (unknown) amount of arguments:
template < typename... T >
Derived( T&&... args ) : Base( std::forward< T >( args )... )
{
}