Cast Object - get null

Namespace rswhite4 at googlemail.com
Wed Apr 18 12:27:20 PDT 2012


On Wednesday, 18 April 2012 at 19:18:42 UTC, Namespace wrote:
> I see i must write
>
> if (vs2 == cast(Vector2s)(vf)) {
> 	writeln("equal");
> }
>
> That is unacceptable. Is this the only possibility?
> I thought that opEquals can cast this intern. It would seem 
> that D code isn't so brief as i thought and hoped before.

I was wrong, event with
if (vs2 == cast(Vector2s)(vf)) {
it doesn't work.
I get still this compiler error:

cast.d(308): Error: template instance opCast!(Object) 
opCast!(Object) does not m
atch template declaration opCast(U) if (is(Unqual!(U) == 
Vector2D!(byte)) || is(
Unqual!(U) == Vector2D!(ubyte)) || is(Unqual!(U) == 
Vector2D!(short)) || is(Unqu
al!(U) == Vector2D!(ushort)) || is(Unqual!(U) == Vector2D!(int)) 
|| is(Unqual!(U
) == Vector2D!(uint)) || is(Unqual!(U) == Vector2D!(long)) || 
is(Unqual!(U) == V
ector2D!(ulong)) || is(Unqual!(U) == Vector2D!(float)) || 
is(Unqual!(U) == Vecto
r2D!(double)) || is(Unqual!(U) == Vector2D!(real)))
cast.d(308): Error: function expected before (), not 
vs2.opCast!(Object) of type
  void
cast.d(308): Error: template instance opCast!(Object) 
opCast!(Object) does not m
atch template declaration opCast(U) if (is(Unqual!(U) == 
Vector2D!(byte)) || is(
Unqual!(U) == Vector2D!(ubyte)) || is(Unqual!(U) == 
Vector2D!(short)) || is(Unqu
al!(U) == Vector2D!(ushort)) || is(Unqual!(U) == Vector2D!(int)) 
|| is(Unqual!(U
) == Vector2D!(uint)) || is(Unqual!(U) == Vector2D!(long)) || 
is(Unqual!(U) == V
ector2D!(ulong)) || is(Unqual!(U) == Vector2D!(float)) || 
is(Unqual!(U) == Vecto
r2D!(double)) || is(Unqual!(U) == Vector2D!(real)))
cast.d(308): Error: function expected before (), not 
vf.opCast().opCast!(Object)
  of type void


More information about the Digitalmars-d-learn mailing list