variadic funtions

Tomas Lindquist Olsen tomas at famolsen.dk
Mon Feb 12 19:02:03 PST 2007


Jarrett Billingsley wrote:

> Not with "normal" functions.  Usually the convention is to declare "..."
> and "TypeInfo[] arguments, va_list argptr" versions of your function so
> that other variadic funcs can call it
> 

Guess that is what I was trying to avoid.

> void foo(...)
> {
>     vfoo(_arguments, _argptr);
> }
> 
> void vfoo(TypeInfo[] arguments, va_list argptr)
> {
>     vbar(arguments, argptr);
> }
> 
> void bar(...)
> {
>     vbar(_arguments, _argptr);
> }
> 
> void vbar(TypeInfo[] arguments, va_list argptr)
> {
>     // The only way to do this..
>     dout.writefx(arguments, argptr, true);
> }
> 

Thanx for this I wasn't aware of OutStream.writefx . It will work for me
just fine.

> With variadic templates, it becomes much more straightforward, although
> your output code can become bloated

Yeah I don't want to go this way. Though it's cool that a tuple can be
passed as variadic args.

Thanx very much for your reply :)


More information about the Digitalmars-d-learn mailing list