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?
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/
The three dots '...' are called an ellipsis. Using them in a function makes that function a variadic function. To use them in a function declaration means that the function will accept an arbitrary number of parameters after the ones already defined.
An ellipsis (plural: ellipses) is a punctuation mark consisting of three dots. Use an ellipsis when omitting a word, phrase, line, paragraph, or more from a quoted passage. Ellipses save space or remove material that is less relevant.
The "Three Dots" in java is called the Variable Arguments or varargs. It allows the method to accept zero or multiple arguments. Varargs are very helpful if you don't know how many arguments you will have to pass in the method.
operator in C/C++ The dot (.) operator is used for direct member selection via object name. In other words, it is used to access the child object.
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 )... )
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With