What's the difference between:
import core.stdc.stdlib : malloc; auto x = malloc(s)[0..s];
and
auto x = cast(T)malloc(s);
?
I have been using the last but I saw in some code examples, like this[1] the first being used. What's the difference? in the first one bounds checking is performed, giving an error right away, right? whereas the cast would just turn the null into the class reference and manual check need to be done later. Is that the reason?
[1]: https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation