Simen kjaeraas Wrote:

> Worth adding:
> Even if non-null references/pointers cannot be perfectly implemented in a
> library, they may still be a worthwhile addition to Phobos, to mark
> function arguments and the like.

Hmm... this doesn't work:

struct NonNull(T)
{
        T value;
        this(T v)
        {
                assert(value);
                value=v;
        }
}

class A {}

void foo(NonNull!A a){}

void goo()
{
        A a=new A();
        foo(a);
}

test.d(23): Error: function test.foo (NonNull!(A) a) is not callable using 
argument types (A)
test.d(23): Error: cannot implicitly convert expression (a) of type test.A to 
NonNull!(A)

Reply via email to