static code generation
    anonymous 
    anonymous at example.com
       
    Sun Dec  9 11:09:47 PST 2012
    
    
  
On Sunday, 9 December 2012 at 10:42:40 UTC, js.mdnq wrote:
> How can I create mixes of stringified code and code itself?
[...]
> mixin template GenStruct(stringname)
> {
>      struct stringname ~ "alpha"
>      {
>          ....
>      }
> }
>
>
> mixin GenStruct!("Helpme");
>
> would be equivalent to do the following
>
> struct Helpmealpha
> {
>     ....
> }
In this particular case you can do this:
mixin template GenStruct(string stringname)
{
      struct S
      {
          ....
      }
      mixin("alias S " ~ stringname ~ "alpha;");
}
    
    
More information about the Digitalmars-d-learn
mailing list