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
12
votes
2 answers
How to write a Doxygen comment for variadic function, i.e., a function with undefined number of arguments?
I am trying to write a doxygen block comment for a function with unlimited number of parameters, then I couldn't find a right tag for it. Supplied parameters should all be strings, and they will be concatenated in the function to form a new…

Joon
- 9,346
- 8
- 48
- 75
12
votes
4 answers
Passing variadic args in Swift 4 for os_log
I am trying to write a convenience wrapper for os_log in Swift 4 / iOS 11, but I've run into an uphill battle with passing the variadic arguments.
Basically, I want to write a function that looks like the following.
static let logger =…

smithco
- 679
- 5
- 17
12
votes
7 answers
template template parameter expansion for variadic templates
I recently learned about the existence of template template parameters and was now wondering if something like this would be possible:
template class Container, typename... args>
struct ContainerTemplate
{
using container =…

ACB
- 1,607
- 11
- 31
12
votes
1 answer
C++ variadic template unusual example
What does the following construction mean?
#include
template struct s;
int main() {
int i = s<,>::xxx;
std::cout << i << std::endl;
}
It is compiled by gcc 4.4.5+ and when executed outputs 0.

Igor Milyakov
- 602
- 5
- 7
11
votes
1 answer
Calling a variadic function inside a variadic function in Javascript?
I have two function a() and b(), both are variadic functions, let say when I call function a() like this :
a(arg0, arg1, arg2, arg3, ...., argn);
then the function b() will be called as well inside a(), but without the first argument "arg0" in the…

Teiv
- 2,605
- 10
- 39
- 48
11
votes
1 answer
Variadic macros with 0 arguments in C99
I have some debugging code that looks like the following:
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)
void __my_error(const char*loc, const char *fmt, ...);
#define my_error(fmt, ...)…

Michael Mior
- 28,107
- 9
- 89
- 113
11
votes
1 answer
Mixins, variadic templates, and CRTP in C++
Here's the scenario: I'd like to have a host class that can have a variable number of mixins (not too hard with variadic templates--see for example http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.144). However, I'd also like the mixins…

Eitan
- 862
- 1
- 7
- 17
10
votes
3 answers
Passing references to Variadic templates
I'm working on an Event library and I'm facing a problem with Variadic templates.
All is working very nice except the fact that I can't pass references as parameters...
Here is a very simplified example wrote to expose my problem.
struct…

Valkea
- 1,216
- 1
- 12
- 26
10
votes
2 answers
Compilation Error on Recursive Variadic Template Function
I've prepared a simple variadic template test in Code::Blocks, but I'm getting an error:
No matching function for call to 'OutputSizes()'
Here's my source code:
#include
#include
using namespace std;
template

Maxpm
- 24,113
- 33
- 111
- 170
10
votes
1 answer
Is it possible to trigger compile time error with custom library in golang?
Let's say, I have min() (just for example) a variadic function to define the smallest value from multiple values provided.
If the caller don't provided any parameter, I want to halt compile process (as this would be the bug in the caller, not error…

rahmat
- 1,727
- 16
- 35
10
votes
6 answers
Passing many functions and storing all their results in a tuple
Consider this output:
int foo (int, char) {std::cout << "foo\n"; return 0;}
double bar (bool, double, long ) {std::cout << "bar\n"; return 3.5;}
bool baz (char, short, float) {std::cout << "baz\n"; return true;}
int main() {
const auto tuple…

prestokeys
- 4,817
- 3
- 20
- 43
10
votes
1 answer
Passing zero argument pack to printf
I have created a class which has a variadic template method. This method calls printf function. When passing zero arguments to the method, I get a compile warning by gcc saying:
warning: format not a string literal and no format arguments…

ztik
- 3,482
- 16
- 34
10
votes
1 answer
Is it the compiler or just me: Inheriting from variadic template consisting of lambdas
I have some code which works under GCC but fails to compile under Visual Studio 2015 (which I realize is in-development but this area I think is supposed to be implemented).
template< typename... T >
class inherit : public…

qeadz
- 1,476
- 1
- 9
- 17
10
votes
1 answer
Container for different functions?
I'm trying to implement a container class for different functions where I can hold function pointers and use it to call those functions later. I'll try to discribe my problem more accurate.
As example, I have 2 different test functions:
int…

shtille
- 133
- 5
9
votes
3 answers
Template function with multiple parameters of same type
I'm trying to create a function that can take multiple parameters of the same type, passed in as a template. The number of arguments is known in compile time:
struct Foo
{
int a, b, c;
};
template
void fun(T…

wjan
- 93
- 1
- 5