ref type versus ptr type on input
anonymous
anonymous at example.com
Sun Dec 29 14:30:37 PST 2013
On Sunday, 29 December 2013 at 22:11:22 UTC, monarch_dodra wrote:
> On Sunday, 29 December 2013 at 21:47:52 UTC, Namespace wrote:
> Well, a ref *can't* be null. In terms of default value, both
> can have them, in terms of referencing a static object though.
>
> The only functional difference I know of in pass-by-ref vs
> pass-by-pointer is indeed the null pointer:
> - Pass by pointer means you *can* pass a null (yay).
> - But pass by ref means the implementation does not have to
> worry about null references (yay).
bool isNullRef(ref int i)
{
return &i is null;
}
void main()
{
int* np = null;
assert(isNullRef(*np));
}
More information about the Digitalmars-d-learn
mailing list