Mixin templates accessing mixed out scope

Prudence via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 12 10:02:30 PDT 2015


On Saturday, 12 September 2015 at 14:30:16 UTC, Ali Çehreli wrote:
> On 09/12/2015 06:37 AM, Prudence wrote:
>>
>> Says the creating new SingleStore is not an expression
>
> Reduced:
>
> mixin template ObjectStore(TKey)
> {
>     class SingleStore
>     {
>         static void New()    // Removing 'static' compiles
>         {
>             new SingleStore();
>         }
>     }
> }
>
> class MyStore
> {
>     mixin ObjectStore!(int);
> }
>
> void main()
> {
>     auto s = new MyStore();
> }
>
> Error: type SingleStore is not an expression
>
> Ali

Are you saying this is a bug or something else? The only 
alternative I can think of is to use string mixins but this 
method should work?


More information about the Digitalmars-d-learn mailing list