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
9
votes
3 answers
reuse of variadic arguments
I have a question regarding restarting variadic argument lists (va_list).
Basically I want to do something like this:
void someFunc(char* fmt, ...) {
va_list ap;
va_start(fmt, ap);
otherFuncA(fmt, ap);
// restart ap
otherFuncB(fmt, ap);
…

Thargon
- 424
- 1
- 3
- 12
9
votes
3 answers
VS2010 C++ variadic template example
I have a class template and I can't seem to figure out how to perform a Variadic Template style instantiation.
Here is the "code" so far of what I'm looking for:
template
class CFunctorStartExT
{
friend…

BabelFish
- 899
- 2
- 9
- 20
9
votes
5 answers
passing variable number of arguments
Can we pass variable number of arguments to a function in c?

Shweta
- 5,198
- 11
- 44
- 58
9
votes
4 answers
Function overloading where parameters only differ by ellipses
I've got this logging system for which I'm looking to shortcut some of the string manipulation.
The logging system is used via functional macros which then forward to a single function call. E.g. #define Warning(...) LogMessage(eWarning,…

dash-tom-bang
- 17,383
- 5
- 46
- 62
9
votes
2 answers
Variadic templates: Interlacing multiple packs
Given any number of packs, take the first type from each pack, put them together. Then the second type from each pack, put them together, etc... Then merge them all. Any leftoevers will repeat the process among themselves. For example, using…

prestokeys
- 4,817
- 3
- 20
- 43
9
votes
2 answers
Extract just the argument type list from decltype(someFunction)
I have a variadic template that represents a list of parameters for a function, eg:
void myFunc (int,int,std::string) { }
template class MyTemplateClass { };
...
MyTemplateClass myConcrete; // for use with…

gimmeamilk
- 2,016
- 5
- 24
- 36
8
votes
3 answers
How to pass multiple return values to a variadic function?
I have a Go function which returns two integer values. Below is the function
func temp() (int, int){
return 1,1
}
Is it possible to put temp function directly into a Println and print both the outputs using string formatting as…

rawwar
- 4,834
- 9
- 32
- 57
8
votes
1 answer
How to find the length of a parameter pack?
Suppose I have a variadic template function like
template
unsigned length(Args... args);
How do I find the length of the parameter list using the length function ?

Eternal Learner
- 3,800
- 13
- 48
- 78
8
votes
2 answers
How to write C function accepting (one) argument of any type
I am implementing simple library for lists in C, and I have a problem with writing find function.
I would like my function to accept any type of argument to find, both:
find(my_list, 3) and find(my_list, my_int_var_to_find).
I already have…

Bartek Chaber
- 236
- 1
- 3
- 7
7
votes
2 answers
What is the difference between lambda capture [&args...] and [...args = std::forward(args)]
I'm writing a simple game with Entity Component System. One of my components is NativeScriptComponent. It contains the instance of my script. The idea is that I can create my NativeScriptComponent anytime and then Bind to it any class implementing…

Kyriet
- 401
- 5
- 8
7
votes
4 answers
Handling a void variable in a templatized function in C++11
I have a template class that must perform some operation before calling a function whose parameters and return type are generic.
This is the method:
template
ReturnType function (Args ...args) {
// prepare…

HappyCactus
- 1,935
- 16
- 24
7
votes
2 answers
CPP/GPP in Fortran variadic macro (plus Fortran // concatenation)
I'm trying to compile a huge, world-renowned numerical weather prediction code - written mostly in Fortran 90 - that uses cpp extensively, and successfully, with PGI, Intel and gfortran. Now, I've inherited a version where experts have added…

DonMorton
- 393
- 2
- 11
7
votes
1 answer
Golang Join array interface
I try to create bulk insert. I use gorm github.com/jinzhu/gorm
import (
"fmt"
dB "github.com/edwinlab/api/repositories"
)
func Update() error {
tx := dB.GetWriteDB().Begin()
sqlStr := "INSERT INTO city(code, name) VALUES (?, ?),(?,…

user2486312
- 75
- 8
7
votes
1 answer
How to write a generic variadic lambda that discards its parameters?
I want to write a lambda that takes an arbitrary number of arguments by universal reference and ignores them entirely. The obvious method would be to use the syntax for a variadic universal parameter pack and omit the parameter name:
auto my_lambda…

ecatmur
- 152,476
- 27
- 293
- 366
7
votes
2 answers
How do I compile variadic templates conditionally?
Is there a macro that tells me whether or not my compiler supports variadic templates?
#ifdef VARIADIC_TEMPLATES_AVAILABLE
template void coolstuff(Args&&... args);
#else
???
#endif
If they are not supported, I guess I would…

fredoverflow
- 256,549
- 94
- 388
- 662