enum function can't be passed into template?

Zhenya zheny at list.ru
Sun Jan 20 06:54:35 PST 2013


On Sunday, 20 January 2013 at 14:51:51 UTC, Philippe Sigaud wrote:
> On Sun, Jan 20, 2013 at 3:21 PM, Zhenya <zheny at list.ru> wrote:
>> Hi!
>> Am I doing something wrong?
>>
>> import std.stdio;
>>
>> template gun(alias f)
>> {
>>         void gun()
>>         {
>>                 f();
>>         }
>> }
>>
>> void main()
>> {
>>         auto str = "hello";
>>         enum fun = (){writeln(str);};//replace enum -> auto to 
>> compile
>>         gun!fun();
>> }
>
> fun depends on str, which is a runtime value. Either make str 
> an enum
> or put them in the module scope (which will make the auto's 
> enum's)
Thank you!


More information about the Digitalmars-d-learn mailing list