On Saturday, 26 September 2020 at 11:30:23 UTC, k2aj wrote:

It does work, the problem is that scoped returns a Voldemort type, so you have to use typeof(scoped!SomeClass(someConstructorArgs)) to declare a field. Gets really annoying when doing it with any class that doesn't have a zero-argument constructor, especially in generic code.

class Foo {}

class Bar {
    typeof(scoped!Foo()) foo;
    this() {
        foo = scoped!Foo();
    }
}

Thanks, so what we really need is a new scope template that declares the the variables in the class and possible a template for running the constructor?

Reply via email to