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
4
votes
1 answer
C++ variadic templates unresolved external of virtual abstract
Today I wrote code for my project, and got unresolved external of linker, code must generate class with multiple virtual abstract methods - as base of class collections. So I decide use variadic templates for this task - but got error.
template

user3477753
- 41
- 1
4
votes
1 answer
Variadic Macro without __VA_ARGS__
So, this is basically what I want to do:
#define RS03(obj, a1, a2, a3) {if (_str1 == #a1) _file >> _##a1; if (_str1 == #a2) _file >> _##a2;if (_str1 == #a3) _file >> _##a3; obj (_##a1, _##a2, _##a3);}
This is the case of three arguments, but I also…

Richter Bernadell
- 61
- 5
4
votes
3 answers
Check for arguments type in a variadic template declaration
I got a plain variadic template declaration, just like the classic one:
template
class VariadicTemplate;
What I need to achieve is in by letting the VariadicTemplate class do perform some type checking; the variadic template…

user3004291
- 71
- 1
- 4
4
votes
1 answer
How to access va_list inside subsequent block
The method signature is...
- (void)blahBlahBlah:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2) {
va_list args; va_start(args,format);
void(^SOME_BLOCK)(void) = ^{ [Heathens prayToJesusWith:
[NSString.alloc…

Alex Gray
- 16,007
- 9
- 96
- 118
4
votes
1 answer
Using variadic template as parameter for both class and method
My question is about the following piece of code:
template
class A
{
public:
template
static void a() { }
};
template
class B
{
public:
template…

user1286875
- 193
- 1
- 6
4
votes
1 answer
Can I create a prototype for a variadic Python function using ctypes so that a DLL can call this function as a callback?
Here's the scenario: I am using ctypes to load a C DLL into a Python program. I want to register a callback so that code in the DLL can call a function in Python.
This is all great until I want to have the function be variadic. For example, say I…

Jon Evans
- 325
- 3
- 6
4
votes
1 answer
Variadic function in obj-C skips first argument
I'm having a problem passing a variable number of parameters to the function:
-(void)addCharacterToScene:(NSString *)name withFrames:(CCSpriteFrame*)frames,... {
va_list args;
va_start(args, frames);
id arg =…

TCool
- 163
- 1
- 6
4
votes
6 answers
Call function with (unknown) variable number of parameters?
I'm need to send params to the function
array_intersect_key()
but sometimes i'm need to send 2 arrays, sometimes - 3 or more:
array_intersect_key($arr_1, $arr_2);
OR
array_intersect_key($arr_1, $arr_2, $arr_3, $arr_4);

Blueberry Hill
- 119
- 4
- 12
3
votes
2 answers
Swallowing comma in variadic macros on compilers that do not recognise ##
I need to write a variadic macro in C which must take zero or more arguments.
In gcc, that can be achieved by adding "##" after the comma, e.g. ,##____VA_ARGS____ as answered in Variadic macros with zero arguments.
However, the compiler in my build…

Gnubie
- 2,587
- 4
- 25
- 38
3
votes
2 answers
C++ variadic function templates
The concept of variadic templates is quite confusing to me and I want to make it a bit more complex (well I think...).
Let us consider the following code:
template
class base
{
template
virtual void…

Royi Freifeld
- 629
- 2
- 11
- 31
3
votes
1 answer
Cartesian product of n ranges
I am rewriting a python program into rust and I am struggling to translate this line:
itertools.product(range(0,8), repeat=n)
What I am trying to achieve is something like this: https://pastebin.com/ceEA5E3q (but so that I can change the number of…

artemetra
- 45
- 4
3
votes
1 answer
Using a custom type with va_arg
mystruct_t v = va_arg(a_list, mystruct_t);
Is this okay (using a custom data type that's >= the size of an int) as far as C specs go?

Edwin Skeevers
- 309
- 1
- 8
3
votes
2 answers
How to assign variadic/variable arguments in C++
I'm trying to create a function to assign default or input values to several (scalar) parameters using variadic/variable input arguments as:
void set_params(const vector &input, int n, ...) {
va_list args;
va_start (args, n);
for…

Patrick Kwok
- 42
- 10
3
votes
1 answer
Alias to variadic template with no arguments
I found some similar topics, but none seem to give straight answer about my particular problem.
I have a class (let's call it Foo) within some library that we are using across few modules. Now I need to transform this class to be a variadic…

Frosty
- 33
- 2
3
votes
2 answers
Change a function's return type based on size of std::tuple
Problem
The following is a simplified, contrived example of an issue that I'm facing. Essentially, I need an object that can hold an arbitrary number of items, and return those items when needed.
template
class Foo {
public:
…

Quentamia
- 3,244
- 3
- 33
- 42