NonNull template

Walter Bright newshound2 at digitalmars.com
Sat Apr 19 06:11:55 UTC 2025


On 4/17/2025 7:48 PM, Richard (Rikki) Andrew Cattermole wrote:
> ```d
> void main() {
>      func(new int); // ok
>      func(null); // error
> }
> 
> void func(int* ptr) {
>      int v = *ptr;
> }
> ```

It always looks simple in such examples, but then there are things like:

```d
struct S { int a,b; int* p; }

void main()
{
     S s;
     funky(&s);
     func(s.p);
}
```
where trying to track information in structs gets complicated fast.



More information about the Digitalmars-d mailing list