Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Struct Template

Part of TemplatesCategory

Description

This template technique involving a struct is apparently undocumented.

Example

struct foo(T)
{
   T x;

   void getsize()
   {
      printf("%d\n", x.sizeof);
   }
}


void main(char[][] args)
{
   foo!(int) y;
   y.getsize();

   int i;
   printf("%d\n", i.sizeof);

   foo!(creal) r;
   r.getsize();
   printf("%d\n", r.sizeof);
}

Source

Based on digitalmars.D:3895.