Nulling a reference to a class with opAssign ...

Mike vertex at gmx.at
Fri Dec 7 18:28:56 PST 2007


On Sat, 08 Dec 2007 03:13:34 +0100, Jarrett Billingsley  
<kb3ctd2 at yahoo.com> wrote:

> "Mike" <vertex at gmx.at> wrote in message news:op.t2zshuvdkgfkbn at lucia...
> On Fri, 07 Dec 2007 23:25:44 +0100, Frank Benoit
> <keinfarbton at googlemail.com> wrote:
> -------------------
> Ok ... got it:
>
> class Foo(T)
> {
> T opAssign(T v) { return v; }
> }
>
> void main()
> {
> auto foo = new Foo!(float)();
> foo = cast(Foo!(float))null; // Works
> foo = null;                  // Error: Can't convert null to float
> }
>
> I'm not sure ... but I think the second assignment should work.
> -------------------
>
> I absolutely think it should.  It's checking for an opAssign, finding it,
> but not falling back to the default behavior.
>
>

Should I file it as a bug?

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list