What is the proper way to handle pointers in variable arguments list?

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Oct 28 13:44:15 PDT 2012


On 29-Oct-12 00:36, Tyro[17] wrote:
> The following fails because the compiler assumes I am trying to
> dereference non-pointer variables. Can this be done?
>
> void main()
> {
>      int i;
>      int* pi;
>      double d;
>      double* pd;
>      char c;
>      char* pc;
>
>      scan(i, pi, d, pd, c, pc);
> }
>
> void scan(A...)(ref A data)
> {
>      import std.traits;
>      foreach (element; data) {
>          if(isPointer!(typeof(element)) && isIntegral!(typeof(*element))) {
>              *element = 10;
>          }
>      }
> }
>
> Thanks

Well, first things first:
if ---> static if

-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list