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
0
votes
1 answer
Is it possible to create a completely arbitrary private member tuple in a C++11 variadic class constructor?
My apologies if this has been asked before - searched with no definite answer, and I'm beginning to wonder if it is even possible. I am trying to learn C++11 and have run into trouble with variadic templates. I think I grasp (finally) the concept…

thekamz
- 13
- 5
0
votes
2 answers
Passing variable arguments in a C++ variadic template
Say I have a template function that accepts variable arguments and calls other functions with those arguments...
template func(int i, A... args)
{
// do something common
switch (i)
{
case 0: x(args...); break;
case 1:…

user1715664
- 153
- 2
- 10
0
votes
3 answers
formatting with variadic variables
c89
gcc 4.7.4
I was just experimenting with macros like these:
#define LOG_INFO_1(fmt, ...) printf(fmt, __VA_ARGS__)
#define LOG_INFO_2(...) printf(__VA_ARGS__)
And using like this:
LOG_INFO_1("%s:%d", __func__, __LINE__);
LOG_INFO_2("%s:%d",…

ant2009
- 27,094
- 154
- 411
- 609
0
votes
2 answers
Variadic function va_arg() returning incorrect parameters
Problem Partically solved: please read bottom
The variadic function in question, stripped down to the bare simplest is:
inline Variant::Variant(int type, int dims, ...)
{
va_list ap;
va_start (ap, dims);
//Removed Variant handling code…

64bit_twitchyliquid
- 894
- 2
- 10
- 22
-1
votes
1 answer
optional named argument after variadic argument
In PHP 7.x, I had some code like the below:
=$min && $value<=$max)
$sum += $value;
return…

safineh
- 80
- 9
-1
votes
2 answers
Can we have more than one Variadic parameter in swift functions?
According to Apple:
"A function can have multiple variadic parameters. The first parameter that comes after a variadic parameter must have an argument label."
But when I tried doing the same it is giving me following error.
"Only a single variadic…

Developer
- 6,375
- 12
- 58
- 92
-1
votes
1 answer
Create an Array of square numbers with a variadic integer as an input in Swift
I’m new to this and maybe this is a very bad approach, so let me know please.
I want to create an array of integers by a function that use variadic integers as an input and return the square of those integers in an array. But at the end I forced to…

Bezi
- 57
- 1
- 7
-1
votes
1 answer
Is it possible to use Variadic Parameters within Closures?
Refurbished Question
Swift: Combining the use of Variadic Parameters with Closures
Is it possible to make a closure using variadic parameters?
func this(_ hello: (Int...) -> ()) {}
func that(_ yeah: Int...) {}
Here's what works: this(that)
Here's…

0-1
- 702
- 1
- 10
- 30
-1
votes
2 answers
How to generate tuple for variadic templates children?
In brief : how to create variadic tuple from given types's child?
In code below there is erroneous type children in get_children call. The goal is to receive tuple with Child derived from given elements.
template
class Elem{
public:
…

Oleksandr N.
- 15
- 6
-1
votes
1 answer
Print the array index in variadic functions
I want to print the index in the array with random. But I can't.
Main.c:
RastgeleKarakter randomB = overload5_specifiedRandom(6,'g','y','u','c','n','e');
RastgeleKarakter.c
RastgeleKarakter overload5_specifiedRandom(int args,...){
va_list list;
…

Muhammet Ömer
- 145
- 1
- 11
-1
votes
1 answer
Create dynamically null terminated parameters for C binding
For my project I am binding a C++ method to a C function.
This function is from gstreamer and is variadic in this form :
GstElement *gst_element_link_many(GstElement *el1, GstElement* el2 ,[...], nullptr);
Let's say I want to pass a vector to my…

Emmanuel Ruaud
- 39
- 8
-1
votes
1 answer
C++ better way to emplace char* strings into a std::vector?
I am populating a string vector from any of
char[]
char*
std::string
by emplacing them in the std::vector
This code works but is a bit clunky looking and takes three templates to cover variadics and initializer lists.
Is there a more canonical idiom…

Chris Reid
- 460
- 4
- 9
-1
votes
2 answers
autofill arguments in function with items from array
I need to compare all first levels items of a muli-dimensional array and get the intersection values.. But the array doesn't have a fixed number arrays to compare with each other..
Here you have to explicit type each argument in…

clarkk
- 27,151
- 72
- 200
- 340
-1
votes
2 answers
c++ passing sequence upper range to variadic function template
I'm calling APIs in a specific way with the help of templates and I have left one problem with passing a constant parameter.
My try with int bound:
template
static int f3(int bound, CString file, int…

CarpeDiemKopi
- 316
- 3
- 13
-1
votes
1 answer
C++ non recursive function with variable number of args
I have a Matrix template class and I need a function to set it's elements with variable number of args.
I should be able to call it like this:
aghMatrix matrix;
matrix.setItems(2, 3, "torzmiae", "jestdnaci", "tablickore", "wyrazobed",…

Łukasz Szcześniak
- 1,417
- 11
- 23