can't initialize .outer in inner class

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed May 6 01:01:03 PDT 2015


Consider:

void fun()
{
     int x;
     class C
     {
         ...
     }
}

Objects of type C have access to x because they have an .outer 
pseudo-member.

Problem is, emplace() and any other in-situ initialization techniques 
fail (e.g. emplace() will fail with inner classes).

This seems to be a compiler issue - there's no way to initialize outer 
without calling new. What would be a proper fix to this?


Thanks,

Andrei


More information about the Digitalmars-d mailing list