anyway to pass the context of an inner type to a template so it can be constructed?

Alex sascha.orlov at gmail.com
Wed Jun 27 14:01:03 UTC 2018


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.


More information about the Digitalmars-d-learn mailing list