variadic-functions Questions
1
Solved
Trying to grasp Scala 3 type system.
Question:
Is it possible to write a single universal def curry(f: ???) = ... function that accepts f of any arity and returns a curried fn? No compiler plugins...
Hypaesthesia asked 11/2, 2023 at 7:4
1
I am wondering whether the following is possible in Scala:
Given some vector x = (x_1, x_2, ..., x_n) in R^n and a function f that maps R^n to R, I would like to replicate this concept in Scala. Th...
Thalassography asked 23/1, 2023 at 21:58
4
Solved
I have been trying to pass variable arguments to other function in C but it is producing inconsistent result in different runtime environment as well as in different runs in same environment:
int ...
Neutral asked 27/4, 2016 at 6:4
12
Solved
How to count the no of arguments passed to the function in following program:
#include<stdio.h>
#include<stdarg.h>
void varfun(int i, ...);
int main(){
varfun(1, 2, 3, 4, 5, 6);
retu...
Brickkiln asked 12/12, 2010 at 12:40
3
Solved
I'm having trouble with std::initializer_list. I reduced it down to a simple example:
#include <initializer_list>
#include <cstdio>
class Test {
public:
template <typename type&...
Grados asked 13/1, 2014 at 22:24
4
Solved
Goal
I would like to write a function with variable number of parameters (using ...) that calls another function with the same arguments and a new one at the end. Order is important! The example be...
Dreiser asked 11/4, 2018 at 18:6
7
Solved
I'm trying to create a generic wrapper function that takes a function as a template argument and takes the same arguments as that function as its arguments. For example:
template <typename F, F...
Dockery asked 8/4, 2016 at 5:14
3
Solved
I've recently come across the java @SafeVarargs annotation. Googling for what makes a variadic function in Java unsafe left me rather confused (heap poisoning? erased types?), so I'd like to know a...
Nonperformance asked 9/1, 2013 at 8:28
1
Solved
I'm making a embedded linux project and I want to do a simple debug messages library where I can disable my debug messages (using pre-compilation directives) when my code is in production phase and...
Deepfry asked 28/9, 2022 at 12:26
3
Solved
Is it possible a lambda function to have variable number of arguments?
For example, I want to write a metaclass, which creates a method for every method of some other class and this newly created ...
Suds asked 26/5, 2010 at 16:26
5
Solved
So I have a function that takes a variable length argument list, for example:
int avg(int count,...){
//stuff
}
I can call it with avg(4,2,3,9,4); and it works fine. It needs to maintain this f...
Feoff asked 14/8, 2013 at 11:12
5
Solved
I have a method which takes a variable length string (String...) as parameter. I have a List<String> with me. How can I pass this to the method as argument?
Ronaronal asked 25/5, 2013 at 10:9
2
Solved
So I've been practicing to write simple subroutines in FASMW using the CDECL and STDCALL calling conventions and it got me wondering about what the printf function in C would be using.
Also, a defi...
Beshore asked 13/5, 2022 at 12:15
2
Solved
Let's say we have the following method.
void some(int id, int... otherIds) {
}
How can I create a single IntStream with those two arguments?
IntStream.concat(
IntStream.of(id),
Optional.o...
Uncontrollable asked 5/5, 2022 at 3:48
7
Solved
Forgive me if this has been answered already, as I couldn't find it...
Basically I have an object that needs to take a variadic argument list in it's constructor and store the arguments in a vect...
Paschasia asked 20/12, 2012 at 19:13
4
Solved
I'm playing with the great fmt C++ library to format strings more gracefully.
And I'd like to pass a non-variable arguments list to fmt::format. It could be a std::vector, or std::string, or whate...
Armin asked 19/2, 2018 at 23:2
2
Solved
I am relatively new to C++ coming from a Java background so I am not sure if the functionality I am looking for is directly possible.
I am attempting to create a C++ function that accepts two...
Context asked 4/4, 2022 at 7:31
7
Solved
I have 1 interface and 3 class. I would like the class to be able to both implement the interface which need a transform method. This method must exist but there can't be more than one per class. I...
Titos asked 3/6, 2017 at 17:38
4
Solved
I have a function which takes one parameter with a default value. Now I also want it to take a variable number of parameters and forward them to some other function. Function parameters with defaul...
Termination asked 11/2, 2013 at 2:45
6
Solved
How to pass by-name repeated parameters in Scala?
The following code fails to work:
scala> def foo(s: (=> String)*) = {
<console>:1: error: no by-name parameter type allowed here
def...
Repugnance asked 25/4, 2010 at 4:46
1
Solved
Inspired by this answer, I produced this code whose output depends on the compiler:
template <typename... Args>
constexpr auto foo(Args&& ...args, ...) noexcept {
return sizeof...(ar...
Serajevo asked 21/10, 2021 at 9:32
3
Solved
I'd like to define a function f() as follows (just an example) :
val f: (vararg strings: String) -> Unit = { for (str in it) println(str) }
so that I could invoke it with f("a","...
Quickfreeze asked 31/12, 2017 at 21:50
5
Solved
I have this code:
#include <iostream>
using namespace std;
int print(int i)
{
cout << endl << i;
}
template<typename ...Args>
inline void pass(Args&&...args)
{
...
Representation asked 23/11, 2015 at 10:17
17
Solved
How can I write a function that accepts a variable number of arguments? Is this possible, how?
Transposition asked 1/11, 2009 at 18:25
3
Solved
I have a function foo(char *n, ...);
I need to get and use all of optional char parameters.
I had an idea to use
while(va_arg(argPtr, char) != NULL)
{
...
}
to understand when I reach the end ...
Semination asked 20/5, 2016 at 21:20
© 2022 - 2024 — McMap. All rights reserved.