On Wednesday, 27 June 2018 at 14:01:03 UTC, Alex wrote:
On Wednesday, 27 June 2018 at 12:02:10 UTC, aliak wrote:
===
The use case is for a non-nullable type, where I want to guarantee that the value inside will never be null. I can't do it for inner classes though. And I can't allow the user to do something like:

void main() {
    class C {}
    auto s = construct(new C);
}

Because I can't guarantee that's not null.


Cheers,
- Ali

Is there any reason, why you don't want to use a struct? An instance of such is never null, still having access to its context, if it is a function.

Sorry, by non-nullable I meant not null. It's that construct produces a wrapper type that has an internal value that I want to guarantee is not null. So whether T is a struct or class is dependent on the user of construct.

- Ali

Reply via email to