In computer science, an operator or function is variadic if it can take a varying number of arguments; that is, if its arity is not fixed.
Questions tagged [variadic]
668 questions
3
votes
0 answers
ceedling/cmock: mocking variadic functions, or va_list parameter
I tried to mock this code:
int myPrintf(const char *fmt, ...);
int myVprintf(const char *fmt, va_list args);
for both functions some wrong code is generated. For example:
typedef int (* CMOCK_myPrintf_CALLBACK)(const char* fmt, int…

mastupristi
- 1,240
- 1
- 13
- 29
3
votes
5 answers
Is it possible to get the number of arguments on a variadic function?
I've been looking into how to declare functions or class members with a variable number of argument, and came across variadic functions, however I was wondering if there was some way to access the number of arguments pass to the function, without…

joaocandre
- 1,621
- 4
- 25
- 42
3
votes
1 answer
Divorce a parameter pack in a class template
I am trying to write a class template that uses a parameter-pack and implements a member function for each type contained in the parameter-pack.
This is what I have so far:
template
class Myclass {
public:
void…

flashbanger
- 53
- 2
3
votes
0 answers
How to know if function can accept a variable number of parameters?
On the question Get a function's arity it is presented the function.length property. But it does not work for function accepting rest parameters or a variadic number of arguments as function(...variable).
function func1()…

Evandro Coan
- 8,560
- 11
- 83
- 144
3
votes
2 answers
Why is template parameter deduction not working with a variadic template class where only the first two parameters are specified?
I have a variadic template class which takes two fixed template parameters and additionally a variable list of parameters.
When I create an instance I want to specify the first two parameters and have the rest deduced from the arguments passed to…

banzai
- 33
- 4
3
votes
2 answers
What does ... (ellipsis) as one and only function parameter in a function prototype mean in C++?
I´ve came across a function declaration, like:
int vsa_d(...);
with ... as one and only parameter.
I know that with an ellipsis, we can refer to multiple objects, but to what does the ... refer to here?
What does that mean and for what is it meant…

RobertS supports Monica Cellio
- 14,524
- 7
- 33
- 80
3
votes
1 answer
C++ variadic templates deduction logic
I have simple code:
#include
template
class A;
template<>
class A<> {
public:
explicit A() {
std::cout << "empty" << std::endl;
}
};
template
class A {
public:
…

forward32
- 61
- 1
- 1
- 3
3
votes
0 answers
how to doc variadic param in jsdoc?
how to doc variadic param in jsdoc?
and is there a way to doc param of type like "Array of string" ?

aztack
- 4,376
- 5
- 32
- 50
3
votes
2 answers
Variadic Function That Calls Constructor With Given Arguments
Need to create variadic template function with different arg types that will call constructor of T with given arguments, sort of like when creating a thread but reverse (when creating a thread, its constructor calls function at given funct…

DeltaJuliet2k
- 65
- 7
3
votes
1 answer
Acces violation on va_arg
I am trying to create a function that takes a variable number of matrix in parameters and multiply theses to a first one.
I can read a first one using va_arg, but the next call of va_arg will cause an access violation.
Here is how i declare my…

colin
- 51
- 2
- 8
3
votes
1 answer
What do variadic functions get compiled to?
In Java, variadic methods are re-written by the compiler so that they become methods that take an array where the variadic arguments are expected (as per this answer).
What happens in Scala?
My main concern is whether the variadic arguments are…

stefanobaghino
- 11,253
- 4
- 35
- 63
3
votes
1 answer
Kotlin generic class overload?
I want to create some classes with variable number of type argument.
For example, a tuple class:
class Tuple{
//blah
}
class Tuple{
//blah blah
}
class Tuple{
//blah blah blah
}
but it shows "redeclaration" error,…

somebody4
- 505
- 4
- 14
3
votes
1 answer
How can a template parameter pack have other trailing arguments?
In the C++14 draft standard, [temp.param]/11 says:
If a template-parameter of a primary class template or alias template
is a template parameter pack, it shall be the last template-parameter.
If you try compiling the following template, then the…

Constantinos Glynos
- 2,952
- 2
- 14
- 32
3
votes
2 answers
Python Variable Argument to functions
I am learning Python and came across variadic arguments. I don't understand the output that the following code produces:
_list = [11,2,3]
def print_list(*args):
for value in args:
a = value * 10
print(a)
print_list(_list)
When I…

Tesla
- 87
- 11
3
votes
1 answer
variadic CRTP with a typedef
I'm experimenting with some code using a variadic CRTP to create mixins. I'd like the mixins to be templated on a type of the user's choice. And I've basically tried this:
template
class Feature1 {
public:
// why doesn't this…

Evan Teran
- 87,561
- 32
- 179
- 238