Hi guys,

is there any way to use shared members without casting them? Fox example:

class Example {

    private shared HashSet!(string) ex;

    ...

    this() {
        ex = cast(shared) new HashSet!(string)();
    }

    void write() {
        foreach (ref c; cast(HashSet!(string)) ex) {
            std.stdio.writeln(c);
        }
    }
}

Without casting, I always get some errors. My classes contains many different
collections and values, so I've many casts which makes the code at some points
a bit unclear. Is there any way to prevent the casting from/to shared objects?

Reply via email to