use template function without assignment

JS js.mdnq at gmail.com
Tue Jul 30 12:09:30 PDT 2013


On Tuesday, 30 July 2013 at 18:38:23 UTC, Ali Çehreli wrote:
> On 07/30/2013 06:16 AM, Meta wrote:
>
> > Can you post some more code that exhibits exactly the
> behaviour you're
> > describing? I can't replicate the problem you're having with
> the code
> > you provided (nor the code *I* provided).
>
> Ditto.
>
> JS, I wrote the following code for you. Could you please start 
> with it and show us the problem that we are trying to solve.
>
> template Pragma(alias amsg)
> {
>     void Pragma(string file = __FILE__)
>     {
>         pragma(msg, amsg);
>     }
> }
>
> void main()
> {
>     enum msg = "hello";
>     Pragma!msg;
> }
>
> Ali

I already stated why this is not a proper example, I'm not using 
Pragma in run time code(for lack of a better term).

module main;

import std.stdio;


template Pragma(alias amsg)
{
     void Pragma(string file = __FILE__)
     {
         pragma(msg, amsg);
     }
}

template t()
{
     Pragma!("help, this does not work!!!!!!!!!");
}

void main()
{
     enum msg = "hello";
     Pragma!msg;
     t!();
}


More information about the Digitalmars-d-learn mailing list