Skip to main content

Questions tagged [variadic-functions]

A function is variadic if it can accept a variable number of arguments; that is, its arity is not fixed. The abbreviation "varargs" is commonly used to refer to these types of functions.

0 votes
1 answer
37 views

Type for heterogeneous *args

In typed Python, how do you type a *args list that you're expecting to pass to another argument that is a higher kinded function? For example, this function takes a function and its first argument and ...
Mike Samuel's user avatar
1 vote
3 answers
82 views

expand parameter pack with boolean operation

I tried to do function that checks if the argument matches specific values. I think know how to do it with recursion or std::initializer_list, but I want to do it with fold. Here is non working code: ...
Nick's user avatar
  • 10.4k
0 votes
1 answer
168 views

Using `std::apply` to iterate over `std::tuple` [duplicate]

I am trying to call a particular member function in all elements of a tuple using std::apply. This works when I use a lambda but not when defining a free function. Following Template tuple - calling a ...
das_blob's user avatar
4 votes
1 answer
80 views

va_arg - different behavior on Linux and Windows

I did some test code to demonstrate different output on Windows and Linux #include <stdarg.h> #include <stdio.h> void print_vint(va_list args) { int i = va_arg(args, int); printf(&...
zdenko.s's user avatar
  • 992
-2 votes
1 answer
113 views

sizeof(va_list) = 24 not 8

By definition, in stdarg.h typedef char* va_list.so the size of va_list should be 8 not 24 in ubuntu 20.04 64bits gcc 9.4.0, i don't know why i get the size of va_list is 24? I runed the following ...
Vicent's user avatar
  • 1
0 votes
2 answers
49 views

Convert `(String, Int)...` variadic parameter function to Dictionary for ExpressibleByDictionaryLiteral

I have objects that are currently initialized via one-parameter init functions that take an Array or Dictionary. I've realized that I can use ExpressibleByArrayLiteral and ...
pkamb's user avatar
  • 34.6k
1 vote
0 answers
43 views

Unable to propagate variable args from one variadic function to another [duplicate]

I have read the following about passing arguments to variadic functions, https://stackoverflow.com/a/3530807/22299201 #include<stdio.h> #include<string.h> #include<stdarg.h> #define ...
xihare's user avatar
  • 29
2 votes
1 answer
43 views

How do I pass a type based on a variadic type in TypeScript?

TypeScript playground link I'm creating a route handler creator for Express for a project, and I'm trying to make it so that you can pass arbitrary assertions as initial arguments before passing the ...
josh's user avatar
  • 10.1k
4 votes
1 answer
75 views

Function that takes both variadic arguments and a class type?

In C++, is it possible to create a templated function which takes both a class type and a variable number of arguments? The function I'm imagining would work something like this (although this is ...
Enderhippo's user avatar
2 votes
1 answer
65 views

va_args in c from <stdarg.h> does not work correctly

I am trying to write my own printf function in c, but I faced with a problem, when I want to call my functions with this arguments : ft_printf ("Characters: %c %c\n",'s','e'); instead of ...
Negar Nasiri's user avatar
1 vote
1 answer
47 views

`rest*` vs `rest @ _*` when pattern matching in Scala

val List(a, b, c, rest*) = ... val List(a, b, c, rest @ _*) = ... Both seem to work, but I've had situations where the former raises the error "bad simple pattern". Only occasionally ...
Each One Chew's user avatar
1 vote
0 answers
71 views

Can Cython be used to define C-callable variadic functions?

I'm writing a Python library for testing DLLs that implement a particular C API. This library also exposes functionality to the native DLLs through callback functions fetched at runtime. There's a ...
JesseTG's user avatar
  • 2,107
2 votes
2 answers
93 views

Is this use of va_copy undefined behaviour?

I made a function that prints pairs of keys and values, where the keys are trusted compile time literal strings which possibly can contain printf specifiers. Now my question is: is this function legal ...
nect's user avatar
  • 33
0 votes
1 answer
45 views

Searching a way to use different variadic functors basing on condition

I have a runtime boolean verbose that if false excludes some prints to stdout. To fix ideas, consider to have a lot of parts like: void add(const int a, const int b, const bool verbose) { //... ...
MatG's user avatar
  • 714
3 votes
4 answers
78 views

cascaded calls to variadic functions in C

I need to make a wrapper of vprintf, so that multiple implementations of a printf like function can be done. This code demonstrates the issue: #include <stdio.h> #include <stdlib.h> #...
xgon's user avatar
  • 205

15 30 50 per page
1
2 3 4 5
180