variadic args

Anders F Björklund afb at algonet.se
Fri Dec 8 02:38:05 PST 2006


JohnC wrote:

> This is what I do:
> 
> import std.stdarg;
> 
> void resolveArgs(inout TypeInfo[] arguments, inout void* argptr) {
>   if (arguments.length == 2 && arguments[0] is typeid(TypeInfo[]) && 
> arguments[1] is typeid(void*)) {
>     arguments = va_arg!(TypeInfo[])(argptr);
>     argptr = *cast(void**)argptr;
> 
>     if (arguments.length == 2 && arguments[0] is typeid(TypeInfo[]) && 
> arguments[1] is typeid(void*))
>         resolveArgs(arguments, argptr);
>   }
> }

This is not portable to GDC, however. (type of argptr should be va_list)

Comparing typeids with 'is' doesn't always work but using '==' should...

--anders



More information about the Digitalmars-d-learn mailing list