NonNull template

kdevel kdevel at vogtner.de
Sat Apr 19 11:32:44 UTC 2025


On Thursday, 17 April 2025 at 17:36:49 UTC, Dave P. wrote:
> ```d
> struct NonNull(T)
> {
>     T p;
>     T ptr() { return p; }
>     alias this = ptr;
> }
> ```
>
> It works, but the syntax/defaults is backwards. Why does the 
> unusual case of a nullable pointer get the nice syntax while 
> the common case gets the `NonNull!(int*)` syntax?

+1

> Who is going to write that all over their code?

Nobody.


More information about the Digitalmars-d mailing list