digitalmars.D.learn - How to call other variadic function with the same arguments?
- Victor Porton (7/7) Feb 24 2019 Let f be a variadic function:
- JN (11/18) Feb 24 2019 void f(A...)(A a)
- Bastiaan Veelo (5/12) Feb 24 2019 I don’t know if you can, but if at least g is a variadic template
- Paul Backus (4/11) Feb 24 2019 If you must use C-style variadic arguments, then your only choice
Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... }
Feb 24 2019
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote:Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... }void f(A...)(A a) { foreach(t; a) writeln(t); } void g(A...)(A a) { f(a); } g(1, 2, 3);
Feb 24 2019
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote:Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... }I don’t know if you can, but if at least g is a variadic template function, you can: https://run.dlang.io/is/fhxZuV Bastiaan.
Feb 24 2019
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote:Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... }If you must use C-style variadic arguments, then your only choice is to do it the same way you would in C: write a version of `g` that accepts a va_list (like vprintf(3)), and have `f` call that.
Feb 24 2019